]> git.ozlabs.org Git - ppp.git/commitdiff
Merge pull request #305 from pali/ifnamsiz
authorPaul Mackerras <paulus@ozlabs.org>
Sat, 7 Aug 2021 06:59:18 +0000 (16:59 +1000)
committerGitHub <noreply@github.com>
Sat, 7 Aug 2021 06:59:18 +0000 (16:59 +1000)
pppd: Remove usage of incorrect constant MAXIFNAMELEN

pppd/main.c
pppd/options.c
pppd/pppd.h
pppd/sys-linux.c

index db0aa97230c1f25cca4a6134dc2b402939cf0b94..203202fe6ed6ffcbc21cbcf7cd102c58e5b3a9a9 100644 (file)
 
 
 /* interface vars */
-char ifname[MAXIFNAMELEN];     /* Interface name */
+char ifname[IFNAMSIZ];         /* Interface name */
 int ifunit;                    /* Interface unit number */
 
 struct channel *the_channel;
index 0c76a6b5e1422186af9c742d3d80d2850f98f8a1..f3f5e25d6e7e9fb4b9ea5d70532c102e6a60826e 100644 (file)
@@ -121,7 +121,7 @@ int connect_delay = 1000;   /* wait this many ms after connect script */
 int    req_unit = -1;          /* requested interface unit */
 char   path_ipup[MAXPATHLEN];  /* pathname of ip-up script */
 char   path_ipdown[MAXPATHLEN];/* pathname of ip-down script */
-char   req_ifname[MAXIFNAMELEN];       /* requested interface name */
+char   req_ifname[IFNAMSIZ];   /* requested interface name */
 bool   multilink = 0;          /* Enable multilink operation */
 char   *bundle_name = NULL;    /* bundle name for multilink */
 bool   dump_options;           /* print out option values */
@@ -299,7 +299,7 @@ option_t general_options[] = {
 
     { "ifname", o_string, req_ifname,
       "Set PPP interface name",
-      OPT_PRIO | OPT_PRIV | OPT_STATIC, NULL, MAXIFNAMELEN },
+      OPT_PRIO | OPT_PRIV | OPT_STATIC, NULL, IFNAMSIZ },
 
     { "dump", o_bool, &dump_options,
       "Print out option values after parsing all options", 1 },
index 465c1bf8617a5964c29ba68aaaa7e94e4295a043..ba62ca5a7fc91c33d643573bd346e5c0514fea50 100644 (file)
@@ -60,6 +60,7 @@
 #include <sys/types.h>         /* for u_int32_t, if defined */
 #include <sys/time.h>          /* for struct timeval */
 #include <net/ppp_defs.h>
+#include <net/if.h>
 #include "patchlevel.h"
 
 #ifdef INET6
@@ -75,8 +76,6 @@
 #define MAXARGS                1       /* max # args to a command */
 #define MAXNAMELEN     256     /* max length of hostname or name for auth */
 #define MAXSECRETLEN   256     /* max length of password or secret */
-#define MAXIFNAMELEN   32      /* max length of interface name; or use IFNAMSIZ, can we
-                                  always include net/if.h? */
 
 /*
  * If PPP_DRV_NAME is not defined, use the default "ppp" as the device name.
@@ -329,7 +328,7 @@ extern int  max_data_rate;  /* max bytes/sec through charshunt */
 extern int     req_unit;       /* interface unit number to use */
 extern char    path_ipup[MAXPATHLEN]; /* pathname of ip-up script */
 extern char    path_ipdown[MAXPATHLEN]; /* pathname of ip-down script */
-extern char    req_ifname[MAXIFNAMELEN]; /* interface name to use */
+extern char    req_ifname[IFNAMSIZ]; /* interface name to use */
 extern bool    multilink;      /* enable multilink operation */
 extern bool    noendpoint;     /* don't send or accept endpt. discrim. */
 extern char    *bundle_name;   /* bundle name for multilink */
index 8f4f2a7d2775d727792cf29eb8fcebf9709063c7..e1bb8108ea0964d81d0c4b64ead2132e97aa5889 100644 (file)
@@ -697,11 +697,11 @@ static int make_ppp_unit(void)
 
        if (x == 0 && req_ifname[0] != '\0') {
                struct ifreq ifr;
-               char t[MAXIFNAMELEN];
+               char t[IFNAMSIZ];
                memset(&ifr, 0, sizeof(struct ifreq));
                slprintf(t, sizeof(t), "%s%d", PPP_DRV_NAME, ifunit);
-               strlcpy(ifr.ifr_name, t, IF_NAMESIZE);
-               strlcpy(ifr.ifr_newname, req_ifname, IF_NAMESIZE);
+               strlcpy(ifr.ifr_name, t, IFNAMSIZ);
+               strlcpy(ifr.ifr_newname, req_ifname, IFNAMSIZ);
                x = ioctl(sock_fd, SIOCSIFNAME, &ifr);
                if (x < 0)
                    error("Couldn't rename interface %s to %s: %m", t, req_ifname);