[PATCH 1/2] Error: STRING_NULL

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Jaromír Končický <jkoncick@xxxxxxxxxx>

arptables-v0.0.4/arptables.c:1671: string_null_argument: Function "read(int, void *, size_t)" does not terminate string "*ret".
arptables-v0.0.4/arptables.c:1675: string_null: Passing unterminated string "ret" to "strlen(char const *)", which expects a null-terminated string.
---
 userspace/arptables/arptables.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/userspace/arptables/arptables.c b/userspace/arptables/arptables.c
index 5535ab2..8ef445a 100644
--- a/userspace/arptables/arptables.c
+++ b/userspace/arptables/arptables.c
@@ -1668,10 +1668,12 @@ static char *get_modprobe(void)
 
 	ret = malloc(1024);
 	if (ret) {
-		switch (read(procfile, ret, 1024)) {
+		int read_bytes = read(procfile, ret, 1024);
+		switch (read_bytes) {
 		case -1: goto fail;
 		case 1024: goto fail; /* Partial read.  Wierd */
 		}
+		ret[read_bytes] = '\0';
 		if (ret[strlen(ret)-1]=='\n')
 			ret[strlen(ret)-1]=0;
 		close(procfile);
-- 
1.8.3.1

--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Netfitler Users]     [LARTC]     [Bugtraq]     [Yosemite Forum]

  Powered by Linux