]> git.ipfire.org Git - thirdparty/tor.git/commitdiff
scan-build: Fix harmless sizeof(ptr) in test_oom.c
authorNick Mathewson <nickm@torproject.org>
Sat, 19 Apr 2014 16:50:17 +0000 (12:50 -0400)
committerNick Mathewson <nickm@torproject.org>
Sat, 19 Apr 2014 16:52:00 +0000 (12:52 -0400)
We meant to using random bytes to fill a buffer, up to 3000 at a
time. Instead we were taking them sizeof(void*) at a time.

src/test/test_oom.c

index cc6e532358a572f0086aadc1c658d724de6904d3..989ca1203b342ae1ccb403fd6607001ebbb4a08c 100644 (file)
@@ -82,8 +82,8 @@ add_bytes_to_buf(generic_buffer_t *buf, size_t n_bytes)
   char b[3000];
 
   while (n_bytes) {
-    size_t this_add = n_bytes > sizeof(buf) ? sizeof(buf) : n_bytes;
-    crypto_rand(b, sizeof(b));
+    size_t this_add = n_bytes > sizeof(b) ? sizeof(b) : n_bytes;
+    crypto_rand(b, this_add);
     generic_buffer_add(buf, b, this_add);
     n_bytes -= this_add;
   }