From: Paul Eggert Date: Thu, 28 Jul 2011 20:29:09 +0000 (-0700) Subject: * callproc.c (child_setup): Don't assume strlen fits in int. X-Git-Tag: emacs-pretest-24.0.90~104^2~152^2~129 X-Git-Url: http://git.eshelyaron.com/gitweb/?a=commitdiff_plain;h=860887db5c3c55a502795d89d43176783e0e313d;p=emacs.git * callproc.c (child_setup): Don't assume strlen fits in int. --- diff --git a/src/ChangeLog b/src/ChangeLog index ff5dfc09330..9b9a9686259 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,5 +1,7 @@ 2011-07-28 Paul Eggert + * callproc.c (child_setup): Don't assume strlen fits in int. + * buffer.c: Memory overflow fixes. (overlays_at, overlays_in, record_overlay_string, overlay_strings): Don't update size of array until after memory allocation succeeds, diff --git a/src/callproc.c b/src/callproc.c index ad3eddbdd39..13d1232a346 100644 --- a/src/callproc.c +++ b/src/callproc.c @@ -1145,9 +1145,11 @@ child_setup (int in, int out, int err, register char **new_argv, int set_pgrp, L cleaned up in the usual way. */ { register char *temp; - register int i; + register ptrdiff_t i; i = SBYTES (current_dir); + if (min (PTRDIFF_MAX, SIZE_MAX) - 6 < i) + memory_full (SIZE_MAX); #ifdef MSDOS /* MSDOS must have all environment variables malloc'ed, because low-level libc functions that launch subsidiary processes rely