From: Paul Mackerras Date: Sat, 7 Aug 2021 06:59:18 +0000 (+1000) Subject: Merge pull request #305 from pali/ifnamsiz X-Git-Tag: ppp-2.5.0~60 X-Git-Url: https://git.ozlabs.org/?p=ppp.git;a=commitdiff_plain;h=812e8e5c87da4fd84ae7bc5b6a18c85106188eb3;hp=a9f253259cb0227fb0710960cac4d610eb7b2371 Merge pull request #305 from pali/ifnamsiz pppd: Remove usage of incorrect constant MAXIFNAMELEN --- diff --git a/pppd/main.c b/pppd/main.c index db0aa97..203202f 100644 --- a/pppd/main.c +++ b/pppd/main.c @@ -124,7 +124,7 @@ /* interface vars */ -char ifname[MAXIFNAMELEN]; /* Interface name */ +char ifname[IFNAMSIZ]; /* Interface name */ int ifunit; /* Interface unit number */ struct channel *the_channel; diff --git a/pppd/options.c b/pppd/options.c index 0c76a6b..f3f5e25 100644 --- a/pppd/options.c +++ b/pppd/options.c @@ -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 }, diff --git a/pppd/pppd.h b/pppd/pppd.h index 465c1bf..ba62ca5 100644 --- a/pppd/pppd.h +++ b/pppd/pppd.h @@ -60,6 +60,7 @@ #include /* for u_int32_t, if defined */ #include /* for struct timeval */ #include +#include #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 */ diff --git a/pppd/sys-linux.c b/pppd/sys-linux.c index 8f4f2a7..e1bb810 100644 --- a/pppd/sys-linux.c +++ b/pppd/sys-linux.c @@ -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);