diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2021-12-31 01:13:00 +0100 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2021-12-31 01:13:03 +0100 |
commit | 92e9df9ca031b9b04487a46afd986ab3122183fd (patch) | |
tree | 9e4d8bacb27f7ee3b0544cd0b12c4157aabee758 /src/nss-myhostname | |
parent | nss-systemd: fix alignment of gr_mem (diff) | |
download | systemd-92e9df9ca031b9b04487a46afd986ab3122183fd.tar.xz systemd-92e9df9ca031b9b04487a46afd986ab3122183fd.zip |
nss-myhostname: do not apply non-zero offset to null pointer
Fixes https://github.com/systemd/systemd/issues/21935#issuecomment-1003216503.
Diffstat (limited to 'src/nss-myhostname')
-rw-r--r-- | src/nss-myhostname/nss-myhostname.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/nss-myhostname/nss-myhostname.c b/src/nss-myhostname/nss-myhostname.c index 3536c5fc83..67b1554d27 100644 --- a/src/nss-myhostname/nss-myhostname.c +++ b/src/nss-myhostname/nss-myhostname.c @@ -39,10 +39,8 @@ enum nss_status _nss_myhostname_gethostbyname4_r( const char *canonical = NULL; int n_addresses = 0; uint32_t local_address_ipv4; - struct local_address *a; size_t l, idx, ms; char *r_name; - unsigned n; PROTECT_ERRNO; BLOCK_SIGNALS(NSS_SIGNALS_BLOCK); @@ -136,7 +134,9 @@ enum nss_status _nss_myhostname_gethostbyname4_r( } /* Fourth, fill actual addresses in, but in backwards order */ - for (a = addresses + n_addresses - 1, n = 0; (int) n < n_addresses; n++, a--) { + for (int i = n_addresses; i > 0; i--) { + struct local_address *a = addresses + i - 1; + r_tuple = (struct gaih_addrtuple*) (buffer + idx); r_tuple->next = r_tuple_prev; r_tuple->name = r_name; |