Fix segmentation fault during socket reading
authorVasilis Tsiligiannis <b_tsiligiannis@silverton.gr>
Sat, 10 Jan 2009 00:13:44 +0000 (02:13 +0200)
committerVasilis Tsiligiannis <b_tsiligiannis@silverton.gr>
Sat, 10 Jan 2009 00:13:44 +0000 (02:13 +0200)
We were trying to malloc using realloc without initializing
buffer pointer to NULL

lib/quagga/src/quagga.c

index 65d1c46..c29543b 100644 (file)
@@ -306,7 +306,11 @@ static unsigned char *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);