@@ -19,6 +19,7 @@
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
+#include <scratch_buffer.h>
#include <stdint.h>
#include <nss.h>
@@ -37,6 +38,8 @@ LINE_PARSER
char *addr;
char *cp;
int n = 1;
+ struct scratch_buffer sbuf;
+ scratch_buffer_init (&sbuf);
STRING_FIELD (result->n_name, isspace, 1);
@@ -58,7 +61,11 @@ LINE_PARSER
}
if (n < 4)
{
- char *newp = (char *) alloca (strlen (addr) + (4 - n) * 2 + 1);
+ if (!scratch_buffer_set_array_size (
+ &sbuf, 1, strlen (addr) + (4 - n) * 2 + 1))
+ return -1;
+ char *newp = sbuf.data;
+
cp = stpcpy (newp, addr);
do
{
@@ -71,6 +78,7 @@ LINE_PARSER
}
result->n_net = __inet_network (addr);
result->n_addrtype = AF_INET;
+ scratch_buffer_free (&sbuf);
})