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
of memory. [RT #32960]
......
......@@ -151,7 +151,8 @@ getlocbyaddr (addr, mask)
struct in_addr netaddr;
u_int32_t a;
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)
{
......@@ -162,13 +163,12 @@ getlocbyaddr (addr, mask)
themask = *mask;
}
text_addr = (char *) malloc (256);
text_mask = (char *) malloc (256);
strcpy (text_addr, inet_ntoa (addr));
strcpy (text_mask, inet_ntoa (themask));
if (debug >= 2)
printf ("Testing address %s/%s\n", text_addr, text_mask);
if (mask == NULL)
{
a = ntohl (addr.s_addr);
......
......@@ -70,7 +70,7 @@ static dki_t *dki_alloc ()
dki_estr[0] = '\0';
dki_t *dkp = malloc (sizeof (dki_t));
if ( (dkp = malloc (sizeof (dki_t))) )
if ( dkp != NULL )
{
memset (dkp, 0, sizeof (dki_t));
return dkp;
......
......@@ -120,14 +120,17 @@ static int read_serial_fromfile (const char *fname, unsigned long *serial)
soafound = 0;
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;
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;
}
if ( !soafound )
{
fclose (fp);
return -2; /* no zone file (soa not found) */
}
/* move forward until any non ws is reached */
while ( (c = getc (fp)) != EOF && isspace (c) )
......@@ -136,7 +139,10 @@ static int read_serial_fromfile (const char *fname, unsigned long *serial)
*serial = 0L; /* read in the current serial number */
if ( fscanf (fp, "%lu", serial) != 1 ) /* try to get serial no */
{
fclose (fp);
return -3; /* no serial number found */
}
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