Commit da443681 authored by Mark Andrews's avatar Mark Andrews
Browse files

3533. [contrib] query-loc-0.4.0: memory leaks. [RT #32960]

3532.   [contrib]       zkt: fixed buffer overrun, resource leaks. [RT #32960]
parent c82da216
3533. [contrib] query-loc-0.4.0: memory leaks. [RT #32960]
3532. [contrib] zkt: fixed buffer overrun, resource leaks. [RT #32960]
3531. [bug] win32: A uninitialized value could be returned on out 3531. [bug] win32: A uninitialized value could be returned on out
of memory. [RT #32960] of memory. [RT #32960]
......
...@@ -151,7 +151,8 @@ getlocbyaddr (addr, mask) ...@@ -151,7 +151,8 @@ getlocbyaddr (addr, mask)
struct in_addr netaddr; struct in_addr netaddr;
u_int32_t a; u_int32_t a;
struct in_addr themask; struct in_addr themask;
char *text_addr, *text_mask; char text_addr[sizeof("255.255.255.255")],
text_mask[sizeof("255.255.255.255")];
if (mask == NULL) if (mask == NULL)
{ {
...@@ -162,13 +163,12 @@ getlocbyaddr (addr, mask) ...@@ -162,13 +163,12 @@ getlocbyaddr (addr, mask)
themask = *mask; themask = *mask;
} }
text_addr = (char *) malloc (256);
text_mask = (char *) malloc (256);
strcpy (text_addr, inet_ntoa (addr)); strcpy (text_addr, inet_ntoa (addr));
strcpy (text_mask, inet_ntoa (themask)); strcpy (text_mask, inet_ntoa (themask));
if (debug >= 2) if (debug >= 2)
printf ("Testing address %s/%s\n", text_addr, text_mask); printf ("Testing address %s/%s\n", text_addr, text_mask);
if (mask == NULL) if (mask == NULL)
{ {
a = ntohl (addr.s_addr); a = ntohl (addr.s_addr);
......
...@@ -70,7 +70,7 @@ static dki_t *dki_alloc () ...@@ -70,7 +70,7 @@ static dki_t *dki_alloc ()
dki_estr[0] = '\0'; dki_estr[0] = '\0';
dki_t *dkp = malloc (sizeof (dki_t)); dki_t *dkp = malloc (sizeof (dki_t));
if ( (dkp = malloc (sizeof (dki_t))) ) if ( dkp != NULL )
{ {
memset (dkp, 0, sizeof (dki_t)); memset (dkp, 0, sizeof (dki_t));
return dkp; return dkp;
......
...@@ -120,14 +120,17 @@ static int read_serial_fromfile (const char *fname, unsigned long *serial) ...@@ -120,14 +120,17 @@ static int read_serial_fromfile (const char *fname, unsigned long *serial)
soafound = 0; soafound = 0;
while ( !soafound && fgets (buf, sizeof buf, fp) ) while ( !soafound && fgets (buf, sizeof buf, fp) )
{ {
if ( sscanf (buf, "%*s %*d IN SOA %255s %*s (\n", master) == 1 ) if ( sscanf (buf, "%*s %*d IN SOA %254s %*s (\n", master) == 1 )
soafound = 1; soafound = 1;
else if ( sscanf (buf, "%*s IN SOA %255s %*s (\n", master) == 1 ) else if ( sscanf (buf, "%*s IN SOA %254s %*s (\n", master) == 1 )
soafound = 1; soafound = 1;
} }
if ( !soafound ) if ( !soafound )
{
fclose (fp);
return -2; /* no zone file (soa not found) */ return -2; /* no zone file (soa not found) */
}
/* move forward until any non ws is reached */ /* move forward until any non ws is reached */
while ( (c = getc (fp)) != EOF && isspace (c) ) while ( (c = getc (fp)) != EOF && isspace (c) )
...@@ -136,7 +139,10 @@ static int read_serial_fromfile (const char *fname, unsigned long *serial) ...@@ -136,7 +139,10 @@ static int read_serial_fromfile (const char *fname, unsigned long *serial)
*serial = 0L; /* read in the current serial number */ *serial = 0L; /* read in the current serial number */
if ( fscanf (fp, "%lu", serial) != 1 ) /* try to get serial no */ if ( fscanf (fp, "%lu", serial) != 1 ) /* try to get serial no */
{
fclose (fp);
return -3; /* no serial number found */ return -3; /* no serial number found */
}
fclose (fp); fclose (fp);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment