X-Git-Url: https://git.ozlabs.org/?a=blobdiff_plain;f=pppd%2Fplugins%2Fpppoe%2Fif.c;h=d5a4624fce5fe829d61d035847d373bfc94cc4f9;hb=52a531f7d10bf4f4a80ac9224d2a5a2bffb87d8d;hp=4b13ecc19866eed617fa8ce038d8b2b728ceeba2;hpb=f19193e0b52c75f579092325f1bb6361c55de8ab;p=ppp.git diff --git a/pppd/plugins/pppoe/if.c b/pppd/plugins/pppoe/if.c index 4b13ecc..d5a4624 100644 --- a/pppd/plugins/pppoe/if.c +++ b/pppd/plugins/pppoe/if.c @@ -99,6 +99,7 @@ openInterface(char const *ifname, UINT16_t type, unsigned char *hwaddr) int fd; struct ifreq ifr; int domain, stype; + size_t maxlen; #ifdef HAVE_STRUCT_SOCKADDR_LL struct sockaddr_ll sa; @@ -111,11 +112,18 @@ openInterface(char const *ifname, UINT16_t type, unsigned char *hwaddr) #ifdef HAVE_STRUCT_SOCKADDR_LL domain = PF_PACKET; stype = SOCK_RAW; + maxlen = IFNAMSIZ; #else domain = PF_INET; stype = SOCK_PACKET; + maxlen = sizeof(sa.sa_data); #endif + if (strlen(ifname) >= maxlen) { + error("Can't use interface %.16s: name is too long", ifname); + return -1; + } + if ((fd = socket(domain, stype, htons(type))) < 0) { /* Give a more helpful message for the common error case */ if (errno == EPERM) {