[hackers] [ubase][PATCH] pwdx: fix off-by-one bug

From: Mattias Andrée <maandree_AT_kth.se>
Date: Sat, 26 Mar 2016 15:46:29 +0100

Signed-off-by: Mattias Andrée <maandree_AT_kth.se>
---
 pwdx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pwdx.c b/pwdx.c
index 57adc72..b169d75 100644
--- a/pwdx.c
+++ b/pwdx.c
_AT_@ -31,7 +31,7 @@ main(int argc, char *argv[])
 
 	for (; argc > 0; argc--, argv++) {
 		n = snprintf(path, sizeof(path), "/proc/%s/cwd", *argv);
-		if (n < 0 || n > sizeof(path)) {
+		if (n < 0 || n >= sizeof(path)) {
 			errno = ESRCH;
 		} else {
 			n = readlink(path, target, sizeof(target) - 1);
-- 
2.7.3
Received on Sat Mar 26 2016 - 15:46:29 CET

This archive was generated by hypermail 2.3.0 : Sat Mar 26 2016 - 15:48:19 CET