mirror of
https://github.com/systemd/systemd-stable.git
synced 2025-01-22 22:03:43 +03:00
Merge pull request #21944 from yuwata/nss-systemd-fix-pointer
nss-systemd: fix pointer calculation
This commit is contained in:
commit
63e10c0cd3
@ -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;
|
||||
|
@ -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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user