[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [torsocks/master] Avoid signed/unsigned comparison. Assert bound on size.



commit 1e6d4cf8965f696e5d8111379ef56ce7ad8497cf
Author: Taylor R Campbell <campbell+torsocks@xxxxxxxxxx>
Date:   Tue Jun 16 20:25:59 2015 +0000

    Avoid signed/unsigned comparison. Assert bound on size.
---
 src/common/utils.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/common/utils.c b/src/common/utils.c
index 377dcae..95ec803 100644
--- a/src/common/utils.c
+++ b/src/common/utils.c
@@ -22,6 +22,7 @@
 #include <sys/socket.h>
 #include <assert.h>
 #include <errno.h>
+#include <limits.h>
 #include <stdlib.h>
 #include <string.h>
 
@@ -123,6 +124,7 @@ int utils_tokenize_ignore_comments(const char *_line, size_t size, char **tokens
 
 	assert(_line);
 	assert(tokens);
+	assert(size <= INT_MAX);
 
 	line = strdup(_line);
 	if (!line) {
@@ -145,7 +147,7 @@ int utils_tokenize_ignore_comments(const char *_line, size_t size, char **tokens
 		argc++;
 	}
 
-	if (argc > size) {
+	if (argc > (int)size) {
 		ret = -ENOMEM;
 		goto error;
 	}



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits