xrealloc -> xreallocarray in portable code too.

This commit is contained in:
Darren Tucker 2015-04-30 09:18:11 +10:00
parent 531a57a389
commit d1680d36e1
2 changed files with 4 additions and 4 deletions

View File

@ -738,7 +738,7 @@ sshpam_query(void *ctx, char **name, char **info,
case PAM_PROMPT_ECHO_OFF:
*num = 1;
len = plen + mlen + 1;
**prompts = xrealloc(**prompts, 1, len);
**prompts = xreallocarray(**prompts, 1, len);
strlcpy(**prompts + plen, msg, len - plen);
plen += mlen;
**echo_on = (type == PAM_PROMPT_ECHO_ON);
@ -748,7 +748,7 @@ sshpam_query(void *ctx, char **name, char **info,
case PAM_TEXT_INFO:
/* accumulate messages */
len = plen + mlen + 2;
**prompts = xrealloc(**prompts, 1, len);
**prompts = xreallocarray(**prompts, 1, len);
strlcpy(**prompts + plen, msg, len - plen);
plen += mlen;
strlcat(**prompts + plen, "\n", len - plen);

View File

@ -86,7 +86,7 @@ temporarily_use_uid(struct passwd *pw)
if (saved_egroupslen < 0)
fatal("getgroups: %.100s", strerror(errno));
if (saved_egroupslen > 0) {
saved_egroups = xrealloc(saved_egroups,
saved_egroups = xreallocarray(saved_egroups,
saved_egroupslen, sizeof(gid_t));
if (getgroups(saved_egroupslen, saved_egroups) < 0)
fatal("getgroups: %.100s", strerror(errno));
@ -104,7 +104,7 @@ temporarily_use_uid(struct passwd *pw)
if (user_groupslen < 0)
fatal("getgroups: %.100s", strerror(errno));
if (user_groupslen > 0) {
user_groups = xrealloc(user_groups,
user_groups = xreallocarray(user_groups,
user_groupslen, sizeof(gid_t));
if (getgroups(user_groupslen, user_groups) < 0)
fatal("getgroups: %.100s", strerror(errno));