]> granicus.if.org Git - sudo/commitdiff
Use emalloc2() to allocate N things of a certain size.
authorTodd C. Miller <Todd.Miller@courtesan.com>
Wed, 12 Mar 2003 21:45:51 +0000 (21:45 +0000)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Wed, 12 Mar 2003 21:45:51 +0000 (21:45 +0000)
interfaces.c
sudo.c

index 8d06d2e46d5aac7f3a05276e20ae735178ef825b..b4f843e571a3df2a335cf8849c7262bb9a0be2b1 100644 (file)
@@ -135,7 +135,7 @@ load_interfaces()
        }
     }
     interfaces =
-       (struct interface *) emalloc(sizeof(struct interface) * num_interfaces);
+       (struct interface *) emalloc2(num_interfaces, sizeof(struct interface));
 
     /* Store the ip addr / netmask pairs. */
     for (ifa = ifaddrs, i = 0; ifa -> ifa_next; ifa = ifa -> ifa_next) {
@@ -219,7 +219,7 @@ load_interfaces()
 
     /* Allocate space for the maximum number of interfaces that could exist. */
     n = ifconf->ifc_len / sizeof(struct ifreq);
-    interfaces = (struct interface *) emalloc(sizeof(struct interface) * n);
+    interfaces = (struct interface *) emalloc2(n, sizeof(struct interface));
 
     /* For each interface, store the ip address and netmask. */
     for (i = 0; i < ifconf->ifc_len; ) {
diff --git a/sudo.c b/sudo.c
index 0486181a81e20a9f0eb1e19b2a52b50db2d10b95..aa7f7e05d58c06dfda489b050a68ab067aa67f77 100644 (file)
--- a/sudo.c
+++ b/sudo.c
@@ -567,7 +567,7 @@ init_vars(sudo_mode)
     if ((sudo_mode & MODE_SHELL)) {
        char **dst, **src = NewArgv;
 
-       NewArgv = (char **) emalloc (sizeof(char *) * (++NewArgc + 1));
+       NewArgv = (char **) emalloc2((++NewArgc + 1), sizeof(char *));
        if (user_shell && *user_shell) {
            NewArgv[0] = user_shell;
        } else {