diff options
author | Hauke Mehrtens <hauke@hauke-m.de> | 2019-09-02 21:26:18 +0200 |
---|---|---|
committer | Hauke Mehrtens <hauke@hauke-m.de> | 2019-09-20 21:34:32 +0200 |
commit | 4327ed40d96c95803b2d4d09ddf997c895eea071 (patch) | |
tree | fb8d660d73dbc07837e3837edd3ca4579fc5a983 /libblkid-tiny | |
parent | 9b3eb63d686b6d97a537f30b3bb6e29a7dec32a8 (diff) | |
download | fstools-4327ed40d96c95803b2d4d09ddf997c895eea071.tar.gz |
mkdev: Avoid out of bounds read
readlink() truncates and does not null terminate the string when more
bytes would be written than available. Just increase the char array by
one and assume that there is a problem when all bytes are needed.
Coverity: #1330087, #1329991
Signed-off-by: Hauke Mehrtens <hauke@hauke-m.de>
Diffstat (limited to 'libblkid-tiny')
-rw-r--r-- | libblkid-tiny/mkdev.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/libblkid-tiny/mkdev.c b/libblkid-tiny/mkdev.c index a35722b..e8ce841 100644 --- a/libblkid-tiny/mkdev.c +++ b/libblkid-tiny/mkdev.c @@ -31,7 +31,7 @@ #include <syslog.h> -static char buf[PATH_MAX]; +static char buf[PATH_MAX + 1]; static char buf2[PATH_MAX]; static unsigned int mode = 0600; @@ -66,7 +66,7 @@ static void find_devs(bool block) strcpy(path, dp->d_name); len = readlink(buf2, buf, sizeof(buf)); - if (len <= 0) + if (len <= 0 || len == sizeof(buf)) continue; buf[len] = 0; |