diff options
author | Jes Sorensen <jsorensen@fb.com> | 2018-05-31 19:11:21 +0200 |
---|---|---|
committer | Jes Sorensen <jsorensen@fb.com> | 2018-05-31 19:11:21 +0200 |
commit | c1b78589cf042221e22a014332b195b2309cb178 (patch) | |
tree | b765a153cc74489c7e219dcdf07edbe9e4f67c4c /mdopen.c | |
parent | Monitor: Increase size of percentalert to avoid gcc warning (diff) | |
download | mdadm-c1b78589cf042221e22a014332b195b2309cb178.tar.xz mdadm-c1b78589cf042221e22a014332b195b2309cb178.zip |
mdopen: fix gcc 8.1 string overflow error
We already cut symlinks longer than 1000, so rely on this calling
readlink and error out if we are able to read more than 1000 bytes.
Signed-off-by: Jes Sorensen <jsorensen@fb.com>
Diffstat (limited to 'mdopen.c')
-rw-r--r-- | mdopen.c | 8 |
1 files changed, 5 insertions, 3 deletions
@@ -44,7 +44,7 @@ void make_parts(char *dev, int cnt) int nlen = strlen(dev) + 20; char *name; int dig = isdigit(dev[strlen(dev)-1]); - char orig[1024]; + char orig[1001]; char sym[1024]; int err; @@ -58,8 +58,10 @@ void make_parts(char *dev, int cnt) minor_num = minor(stb.st_rdev); odig = -1; } else if (S_ISLNK(stb.st_mode)) { - int len = readlink(dev, orig, sizeof(orig)); - if (len < 0 || len > 1000) + int len; + + len = readlink(dev, orig, sizeof(orig)); + if (len < 0 || len >= (int)sizeof(orig)) return; orig[len] = 0; odig = isdigit(orig[len-1]); |