nss: Get rid of alloca usage in files-network's parse_line
Checks
Context |
Check |
Description |
redhat-pt-bot/TryBot-apply_patch |
success
|
Patch applied to master at the time it was sent
|
redhat-pt-bot/TryBot-32bit |
success
|
Build for i686
|
linaro-tcwg-bot/tcwg_glibc_build--master-arm |
success
|
Testing passed
|
linaro-tcwg-bot/tcwg_glibc_check--master-arm |
success
|
Testing passed
|
linaro-tcwg-bot/tcwg_glibc_build--master-aarch64 |
success
|
Testing passed
|
linaro-tcwg-bot/tcwg_glibc_check--master-aarch64 |
success
|
Testing passed
|
Commit Message
Replace alloca usage with a scratch_buffer.
---
nss/nss_files/files-network.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
@@ -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);
})