From: Paul Eggert Date: Fri, 29 Jul 2011 01:05:39 +0000 (-0700) Subject: * process.c (Fnetwork_interface_list): Check for overflow X-Git-Tag: emacs-pretest-24.0.90~104^2~152^2~106 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=bf2da747e95a3902bf715076aeee947d657c94cd;p=emacs.git * process.c (Fnetwork_interface_list): Check for overflow in size calculation. --- diff --git a/src/ChangeLog b/src/ChangeLog index 748ccc333b2..46d2cdb82f7 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,8 @@ 2011-07-29 Paul Eggert + * process.c (Fnetwork_interface_list): Check for overflow + in size calculation. + * nsterm.h (struct ns_color_table.size, struct ns_color_table.avail): Now ptrdiff_t, not int. * nsterm.m (ns_index_color): Use ptrdiff_t, not int, for table indexes. diff --git a/src/process.c b/src/process.c index 236c27e5c3a..31359a1f1f2 100644 --- a/src/process.c +++ b/src/process.c @@ -3567,6 +3567,12 @@ format; see the description of ADDRESS in `make-network-process'. */) return Qnil; again: + if (min (INT_MAX, min (PTRDIFF_MAX, SIZE_MAX)) / sizeof *ifreqs - 25 + < ifaces) + { + xfree (ifreqs); + memory_full (SIZE_MAX); + } ifaces += 25; buf_size = ifaces * sizeof (ifreqs[0]); ifreqs = (struct ifreq *)xrealloc(ifreqs, buf_size);