From bc57d757a2a5ac2ccbd658c7905c653357fc9da3 Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Mon, 4 Apr 2011 01:13:45 -0700 Subject: [PATCH] * process.c (Fnetwork_interface_info): Avoid possibility of int overflow. --- src/ChangeLog | 1 + src/process.c | 10 +++++----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/ChangeLog b/src/ChangeLog index bea6ffdbc0d..c4c7e4e4abc 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -3,6 +3,7 @@ * process.c (list_processes_1, create_pty, read_process_output): (exec_sentinel): Remove vars that were set but not used. (create_pty): Remove unnecessary "volatile"s. + (Fnetwork_interface_info): Avoid possibility of int overflow. * bytecode.c (exec_byte_code): Rename local to avoid shadowing. diff --git a/src/process.c b/src/process.c index 57b76b67f27..50a068b2339 100644 --- a/src/process.c +++ b/src/process.c @@ -3949,7 +3949,7 @@ FLAGS is the current flags of the interface. */) const struct ifflag_def *fp; int fnum; - any++; + any = 1; for (fp = ifflag_table; flags != 0 && fp->flag_sym; fp++) { if (flags & fp->flag_bit) @@ -3977,7 +3977,7 @@ FLAGS is the current flags of the interface. */) register struct Lisp_Vector *p = XVECTOR (hwaddr); int n; - any++; + any = 1; for (n = 0; n < 6; n++) p->contents[n] = make_number (((unsigned char *)&rq.ifr_hwaddr.sa_data[0])[n]); elt = Fcons (make_number (rq.ifr_hwaddr.sa_family), hwaddr); @@ -3989,7 +3989,7 @@ FLAGS is the current flags of the interface. */) #if defined(SIOCGIFNETMASK) && (defined(HAVE_STRUCT_IFREQ_IFR_NETMASK) || defined(HAVE_STRUCT_IFREQ_IFR_ADDR)) if (ioctl (s, SIOCGIFNETMASK, &rq) == 0) { - any++; + any = 1; #ifdef HAVE_STRUCT_IFREQ_IFR_NETMASK elt = conv_sockaddr_to_lisp (&rq.ifr_netmask, sizeof (rq.ifr_netmask)); #else @@ -4003,7 +4003,7 @@ FLAGS is the current flags of the interface. */) #if defined(SIOCGIFBRDADDR) && defined(HAVE_STRUCT_IFREQ_IFR_BROADADDR) if (ioctl (s, SIOCGIFBRDADDR, &rq) == 0) { - any++; + any = 1; elt = conv_sockaddr_to_lisp (&rq.ifr_broadaddr, sizeof (rq.ifr_broadaddr)); } #endif @@ -4013,7 +4013,7 @@ FLAGS is the current flags of the interface. */) #if defined(SIOCGIFADDR) && defined(HAVE_STRUCT_IFREQ_IFR_ADDR) if (ioctl (s, SIOCGIFADDR, &rq) == 0) { - any++; + any = 1; elt = conv_sockaddr_to_lisp (&rq.ifr_addr, sizeof (rq.ifr_addr)); } #endif -- 2.39.2