From: Eric Sandeen <sandeen@redhat.com>
To: xfs-oss <xfs@oss.sgi.com>
Subject: [PATCH] xfsprogs: properly terminate string in quota's restore_file()
Date: Tue, 25 Aug 2015 11:39:29 -0500 [thread overview]
Message-ID: <55DC9A41.8060006@redhat.com> (raw)
This code copies up to the entire size of devbuffer, and then
tries to use "strlen" to null terminate it.
But strlen works by *finding* the null, so it's at best a
no-op, and at worst not properly terminating the string.
Fix this by placing the null at the last byte of the buffer.
Addresses-Coverity-Id: 1297519
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
---
diff --git a/quota/edit.c b/quota/edit.c
index d226e89..a53a7e6 100644
--- a/quota/edit.c
+++ b/quota/edit.c
@@ -385,7 +385,7 @@ restore_file(
while (fgets(buffer, sizeof(buffer), fp) != NULL) {
if (strncmp("fs = ", buffer, 5) == 0) {
dev = strncpy(devbuffer, buffer+5, sizeof(devbuffer));
- dev[strlen(dev) - 1] = '\0';
+ dev[sizeof(devbuffer) - 1] = '\0';
continue;
}
rtbsoft = rtbhard = 0;
_______________________________________________
xfs mailing list
xfs@oss.sgi.com
http://oss.sgi.com/mailman/listinfo/xfs
next reply other threads:[~2015-08-25 16:39 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-25 16:39 Eric Sandeen [this message]
2015-08-26 11:53 ` [PATCH] xfsprogs: properly terminate string in quota's restore_file() Brian Foster
2015-08-26 21:56 ` Eric Sandeen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=55DC9A41.8060006@redhat.com \
--to=sandeen@redhat.com \
--cc=xfs@oss.sgi.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.