aboutsummaryrefslogtreecommitdiff
path: root/nss/nss_files/files-network.c
diff options
context:
space:
mode:
Diffstat (limited to 'nss/nss_files/files-network.c')
-rw-r--r--nss/nss_files/files-network.c22
1 files changed, 7 insertions, 15 deletions
diff --git a/nss/nss_files/files-network.c b/nss/nss_files/files-network.c
index 90a048b..f08daaf 100644
--- a/nss/nss_files/files-network.c
+++ b/nss/nss_files/files-network.c
@@ -1,5 +1,5 @@
/* Networks file parser in nss_files module.
- Copyright (C) 1996-2024 Free Software Foundation, Inc.
+ Copyright (C) 1996-2025 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
@@ -42,7 +42,8 @@ LINE_PARSER
STRING_FIELD (addr, isspace, 1);
/* 'inet_network' does not add zeroes at the end if the network number
- does not four byte values. We add them ourselves if necessary. */
+ does not contain four byte values. We shift result ourselves if
+ necessary. */
cp = strchr (addr, '.');
if (cp != NULL)
{
@@ -56,20 +57,11 @@ LINE_PARSER
++n;
}
}
- if (n < 4)
- {
- char *newp = (char *) alloca (strlen (addr) + (4 - n) * 2 + 1);
- cp = stpcpy (newp, addr);
- do
- {
- *cp++ = '.';
- *cp++ = '0';
- }
- while (++n < 4);
- *cp = '\0';
- addr = newp;
- }
result->n_net = __inet_network (addr);
+ if (result->n_net == INADDR_NONE)
+ return 0;
+ if (n < 4)
+ result->n_net <<= 8 * (4 - n);
result->n_addrtype = AF_INET;
})