Skip to contentSkip to conversation

rpcdebug: avoid buffer underflow if read() returns 0

PATCH In review Zhi Li 2 participants 2 messages Mar 9, 2023 – Apr 5, 2023

Subsystems (2)
lore
Share & tools
lore

Zhi Li

author
#0 lore raw

PATCH 1/1 rpcdebug: avoid buffer underflow if read() returns 0

---
 tools/rpcdebug/rpcdebug.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/rpcdebug/rpcdebug.c +1 -1
index 68206cc5..ec05179e 100644
@@ -257,7 +257,7 @@ get_flags(char *module)
 		perror(filename);
 		exit(1);
 	}
-	if ((len = read(sysfd, buffer, sizeof(buffer))) < 0) {
+	if ((len = read(sysfd, buffer, sizeof(buffer))) <= 0) {
 		perror("read");
 		exit(1);
 	}
Signature · 1 line
2.39.0
#1 lore raw
Quoted 3 lines · Zhi Li

Committed... (tag: nfs-utils-2-6-3-rc7)

steved.

Quoted 17 lines
---
  tools/rpcdebug/rpcdebug.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
tools/rpcdebug/rpcdebug.c +1 -1
index 68206cc5..ec05179e 100644
@@ -257,7 +257,7 @@ get_flags(char *module)
  		perror(filename);
  		exit(1);
  	}
-	if ((len = read(sysfd, buffer, sizeof(buffer))) < 0) {
+	if ((len = read(sysfd, buffer, sizeof(buffer))) <= 0) {
  		perror("read");
  		exit(1);
  	}