From 860887db5c3c55a502795d89d43176783e0e313d Mon Sep 17 00:00:00 2001 From: Paul Eggert Date: Thu, 28 Jul 2011 13:29:09 -0700 Subject: [PATCH] * callproc.c (child_setup): Don't assume strlen fits in int. --- src/ChangeLog | 2 ++ src/callproc.c | 4 +++- 2 files changed, 5 insertions(+), 1 deletion(-) 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 -- 2.39.2