diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2022-01-03 05:32:05 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-03 05:32:05 +0900 |
commit | 63e10c0cd366bd5720276e6397912143f959d845 (patch) | |
tree | c79a8da34945100c630a4a2af3de3a6c2a753b73 | |
parent | 3c80c7bacf6d2a3add8f48b0d094f40c29079a14 (diff) | |
parent | 92e9df9ca031b9b04487a46afd986ab3122183fd (diff) | |
download | systemd-63e10c0cd366bd5720276e6397912143f959d845.tar.gz |
Merge pull request #21944 from yuwata/nss-systemd-fix-pointer
nss-systemd: fix pointer calculation
-rw-r--r-- | src/nss-myhostname/nss-myhostname.c | 6 | ||||
-rw-r--r-- | src/nss-systemd/nss-systemd.c | 4 |
2 files changed, 5 insertions, 5 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; diff --git a/src/nss-systemd/nss-systemd.c b/src/nss-systemd/nss-systemd.c index 7aea3652c4..36486b96e3 100644 --- a/src/nss-systemd/nss-systemd.c +++ b/src/nss-systemd/nss-systemd.c @@ -238,7 +238,7 @@ static enum nss_status copy_synthesized_group( required += strlen(src->gr_passwd) + 1; required += sizeof(char*); /* ...but that NULL still needs to be stored into the buffer! */ - if (buflen < required) { + if (buflen < ALIGN(required)) { *errnop = ERANGE; return NSS_STATUS_TRYAGAIN; } @@ -250,7 +250,7 @@ static enum nss_status copy_synthesized_group( /* String fields point into the user-provided buffer */ dest->gr_name = buffer; dest->gr_passwd = stpcpy(dest->gr_name, src->gr_name) + 1; - dest->gr_mem = (char **) stpcpy(dest->gr_passwd, src->gr_passwd) + 1; + dest->gr_mem = ALIGN_PTR(stpcpy(dest->gr_passwd, src->gr_passwd) + 1); *dest->gr_mem = NULL; return NSS_STATUS_SUCCESS; |