Skip to contentSkip to conversation

lib: fix length check in safe_sendmsg

PATCH New Richard Palethorpe 2 participants 2 messages Mar 14, 2018 Library code

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 lib: fix length check in safe_sendmsg

It appears that we only check the len parameter against the return value if the len parameter is zero.

---
 lib/safe_net.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/safe_net.c +1 -1
index 9ea9d2b42..96216ee69 100644
@@ -200,7 +200,7 @@ ssize_t safe_sendmsg(const char *file, const int lineno, size_t len,
 			 file, lineno, sockfd, msg, flags);
 	}
 
-	if (!len && (size_t)rval != len) {
+	if (len && (size_t)rval != len) {
 		tst_brkm(TBROK, NULL,
 			 "%s:%d: sendmsg(%d, %p, %d) ret(%zd) != len(%zu)",
 			 file, lineno, sockfd, msg, flags, rval, len);
Signature · 1 line
2.16.2
#1 lore raw

PATCH 1/1 lib: fix length check in safe_sendmsg

Quoted 14 lines · Richard Palethorpe

It appears that we only check the len parameter against the return value if the len parameter is zero.

---
 lib/safe_net.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/safe_net.c +0 -0
index 9ea9d2b42..96216ee69 100644

lib/safe_net.c ssize_t safe_sendmsg(const char *file, const int lineno, size_t len, · line 206

Quoted 8 lines
lib/safe_net.c +1 -1
@@ -200,7 +200,7 @@ ssize_t safe_sendmsg(const char *file, const int lineno, size_t len,
 			 file, lineno, sockfd, msg, flags);
 	}
 
-	if (!len && (size_t)rval != len) {
+	if (len && (size_t)rval != len) {
 		tst_brkm(TBROK, NULL,
 			 "%s:%d: sendmsg(%d, %p, %d) ret(%zd) != len(%zu)",
 			 file, lineno, sockfd, msg, flags, rval, len);

Applied. Nice catch, thank you Richard!