Fix segmentation fault during socket reading
authorVasilis Tsiligiannis <b_tsiligiannis@silverton.gr>
Sun, 28 Feb 2010 14:27:42 +0000 (16:27 +0200)
committerVasilis Tsiligiannis <b_tsiligiannis@silverton.gr>
Sun, 28 Feb 2010 14:27:42 +0000 (16:27 +0200)
We were trying to malloc using realloc without initializing
buffer pointer to NULL

lib/quagga/src/quagga.c

index 05307d4..27ffce0 100644 (file)
@@ -316,7 +316,11 @@ try_read(ssize_t * size)
   uint16_t length, offset;
   int sockstatus;
 
-  offset = *size = bufsize = 0;
+  /* initialize variables */
+  buf = NULL;
+  offset = 0;
+  *size = 0;
+  bufsize = 0;
 
   /* save socket status and set non-blocking for read */
   sockstatus = fcntl(zebra.sock, F_GETFL);