diff options
author | Yuriy M. Kaminskiy | 2016-02-27 17:27:29 +0100 |
---|---|---|
committer | Karel Zak | 2016-03-07 15:11:06 +0100 |
commit | 06fa5817489adb9728f8a29d4cb7602fb48b8bdb (patch) | |
tree | b3a6f1d0db6b1a6d0e340c1297f243c07c1de618 /sys-utils/mountpoint.c | |
parent | lsns.c: fix error return (diff) | |
download | kernel-qcow2-util-linux-06fa5817489adb9728f8a29d4cb7602fb48b8bdb.tar.gz kernel-qcow2-util-linux-06fa5817489adb9728f8a29d4cb7602fb48b8bdb.tar.xz kernel-qcow2-util-linux-06fa5817489adb9728f8a29d4cb7602fb48b8bdb.zip |
misc: safer (and uniform) handling of return value
When `rc` is `INT_MAX`, `rc + 1` result in signed integer overflow.
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'sys-utils/mountpoint.c')
-rw-r--r-- | sys-utils/mountpoint.c | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/sys-utils/mountpoint.c b/sys-utils/mountpoint.c index a43bfd6dd..ad9c1da2e 100644 --- a/sys-utils/mountpoint.c +++ b/sys-utils/mountpoint.c @@ -71,7 +71,7 @@ static int dir_to_device(struct mountpoint_control *ctl) len = snprintf(buf, sizeof(buf), "%s/..", cn ? cn : ctl->path); free(cn); - if (len < 0 || (size_t) len + 1 > sizeof(buf)) + if (len < 0 || (size_t) len >= sizeof(buf)) return -1; if (stat(buf, &pst) !=0) return -1; |