From 06fa5817489adb9728f8a29d4cb7602fb48b8bdb Mon Sep 17 00:00:00 2001 From: Yuriy M. Kaminskiy Date: Sat, 27 Feb 2016 19:27:29 +0300 Subject: 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 --- sys-utils/mountpoint.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'sys-utils/mountpoint.c') 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; -- cgit v1.2.3-55-g7522