From: Mark Whitley Date: Mon, 23 Apr 2001 17:04:41 +0000 (-0000) Subject: Added a sanity check to fix weird bug exposed when sourcing in commands from a X-Git-Tag: 0_52~312 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=4b66dabc76a89a10e4ff07318ff88e3501a4bba5;p=oweals%2Fbusybox.git Added a sanity check to fix weird bug exposed when sourcing in commands from a file with lash. Based on report from Heinz Walter. --- diff --git a/libbb/trim.c b/libbb/trim.c index 78cf235dd..d3be62d93 100644 --- a/libbb/trim.c +++ b/libbb/trim.c @@ -33,7 +33,11 @@ void trim(char *s) { - int len=strlen(s); + int len = strlen(s); + + /* sanity check */ + if (len == 0) + return; /* trim trailing whitespace */ while ( len > 0 && isspace(s[len-1]))