diff options
author | Karel Zak | 2012-07-09 22:26:27 +0200 |
---|---|---|
committer | Karel Zak | 2012-07-09 22:26:27 +0200 |
commit | 657d9adb71ed50275b1ed2a0d4e966032db5ba97 (patch) | |
tree | 071fa200585354a29f51d1e0cf51baa5b4b9ba4e /lib | |
parent | utmpdump: white space fix (diff) | |
download | kernel-qcow2-util-linux-657d9adb71ed50275b1ed2a0d4e966032db5ba97.tar.gz kernel-qcow2-util-linux-657d9adb71ed50275b1ed2a0d4e966032db5ba97.tar.xz kernel-qcow2-util-linux-657d9adb71ed50275b1ed2a0d4e966032db5ba97.zip |
fix buffer overrun in some calls to sscanf
Reported-by: Sergei Antonov <saproj@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/loopdev.c | 2 | ||||
-rw-r--r-- | lib/sysfs.c | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/lib/loopdev.c b/lib/loopdev.c index b759f0c28..b644ae50c 100644 --- a/lib/loopdev.c +++ b/lib/loopdev.c @@ -478,7 +478,7 @@ static int loopcxt_next_from_proc(struct loopdev_cxt *lc) while (fgets(buf, sizeof(buf), iter->proc)) { unsigned int m; - char name[128]; + char name[128 + 1]; if (sscanf(buf, " %u %*s %*s %128[^\n ]", diff --git a/lib/sysfs.c b/lib/sysfs.c index ad90c19c8..7455a30f7 100644 --- a/lib/sysfs.c +++ b/lib/sysfs.c @@ -373,7 +373,7 @@ int sysfs_read_int(struct sysfs_cxt *cxt, const char *attr, int *res) char *sysfs_strdup(struct sysfs_cxt *cxt, const char *attr) { char buf[1024]; - return sysfs_scanf(cxt, attr, "%1024[^\n]", buf) == 1 ? + return sysfs_scanf(cxt, attr, "%1023[^\n]", buf) == 1 ? strdup(buf) : NULL; } |