Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/lib/libpam/modules/pam_exec pam_exec: Convert realloc(x * y)...



details:   https://anonhg.NetBSD.org/src/rev/612abdf3cde9
branches:  trunk
changeset: 990565:612abdf3cde9
user:      nia <nia%NetBSD.org@localhost>
date:      Sat Oct 30 11:34:59 2021 +0000

description:
pam_exec: Convert realloc(x * y) to reallocarr.

Eliminate a now-redundant temporary variable.

diffstat:

 lib/libpam/modules/pam_exec/pam_exec.c |  10 ++++------
 1 files changed, 4 insertions(+), 6 deletions(-)

diffs (41 lines):

diff -r ad87d98f2caf -r 612abdf3cde9 lib/libpam/modules/pam_exec/pam_exec.c
--- a/lib/libpam/modules/pam_exec/pam_exec.c    Sat Oct 30 11:31:51 2021 +0000
+++ b/lib/libpam/modules/pam_exec/pam_exec.c    Sat Oct 30 11:34:59 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: pam_exec.c,v 1.7 2013/12/29 22:54:58 christos Exp $    */
+/*     $NetBSD: pam_exec.c,v 1.8 2021/10/30 11:34:59 nia Exp $ */
 
 /*-
  * Copyright (c) 2001,2003 Networks Associates Technology, Inc.
@@ -38,7 +38,7 @@
 #ifdef __FreeBSD__
 __FBSDID("$FreeBSD: src/lib/libpam/modules/pam_exec/pam_exec.c,v 1.4 2005/02/01 10:37:07 des Exp $");
 #else
-__RCSID("$NetBSD: pam_exec.c,v 1.7 2013/12/29 22:54:58 christos Exp $");
+__RCSID("$NetBSD: pam_exec.c,v 1.8 2021/10/30 11:34:59 nia Exp $");
 #endif
 
 #include <sys/types.h>
@@ -72,7 +72,7 @@
 {
        size_t envlen, i, nitems;
        int pam_err, status;
-       char **envlist, **tmp;
+       char **envlist;
        volatile int childerr;
        pid_t pid;
 
@@ -92,12 +92,10 @@
        for (envlen = 0; envlist[envlen] != NULL; ++envlen)
                /* nothing */ ;
        nitems = sizeof(env_items) / sizeof(*env_items);
-       tmp = realloc(envlist, (envlen + nitems + 1) * sizeof(*envlist));
-       if (tmp == NULL) {
+       if (reallocarr(&envlist, envlen + nitems + 1, sizeof(*envlist)) != 0) {
                openpam_free_envlist(envlist);
                return (PAM_BUF_ERR);
        }
-       envlist = tmp;
        for (i = 0; i < nitems; ++i) {
                const void *item;
                char *envstr;



Home | Main Index | Thread Index | Old Index