Explorar o código

Tweaks on last process-launch patches

Nick Mathewson %!s(int64=14) %!d(string=hai) anos
pai
achega
6a3e4a89a2
Modificáronse 2 ficheiros con 2 adicións e 2 borrados
  1. 1 0
      src/common/util.c
  2. 1 2
      src/test/test_util.c

+ 1 - 0
src/common/util.c

@@ -3616,6 +3616,7 @@ tor_read_all_handle(FILE *h, char *buf, size_t count,
       }
     }
     tor_assert(retval != NULL);
+    tor_assert(strlen(retval) + numread <= count);
     numread += strlen(retval);
   }
 

+ 1 - 2
src/test/test_util.c

@@ -1647,8 +1647,7 @@ test_util_split_lines(void *ptr)
   for (i=0; tests[i].orig_line; i++) {
     sl = smartlist_create();
     /* Allocate space for string and trailing NULL */
-    orig_line = tor_malloc(tests[i].orig_length + 1);
-    memcpy(orig_line, tests[i].orig_line, tests[i].orig_length + 1);
+    orig_line = tor_memdup(tests[i].orig_line, tests[i].orig_length + 1);
     tor_split_lines(sl, orig_line, tests[i].orig_length);
 
     j = 0;