diff options
author | markw <markw@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2001-04-23 17:04:41 +0000 |
---|---|---|
committer | markw <markw@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2001-04-23 17:04:41 +0000 |
commit | 79668692a8641461e58543da9ce704411e74dff5 (patch) | |
tree | b0f9b03c749cdff64ea459ab7d7fc1fb16ea4f49 | |
parent | e34963bfdd979d47409a0fef4088641161f7acd8 (diff) | |
download | busybox-w32-79668692a8641461e58543da9ce704411e74dff5.tar.gz busybox-w32-79668692a8641461e58543da9ce704411e74dff5.tar.bz2 busybox-w32-79668692a8641461e58543da9ce704411e74dff5.zip |
Added a sanity check to fix weird bug exposed when sourcing in commands from a
file with lash. Based on report from Heinz Walter.
git-svn-id: svn://busybox.net/trunk/busybox@2404 69ca8d6d-28ef-0310-b511-8ec308f3f277
-rw-r--r-- | libbb/trim.c | 6 |
1 files changed, 5 insertions, 1 deletions
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 @@ | |||
33 | 33 | ||
34 | void trim(char *s) | 34 | void trim(char *s) |
35 | { | 35 | { |
36 | int len=strlen(s); | 36 | int len = strlen(s); |
37 | |||
38 | /* sanity check */ | ||
39 | if (len == 0) | ||
40 | return; | ||
37 | 41 | ||
38 | /* trim trailing whitespace */ | 42 | /* trim trailing whitespace */ |
39 | while ( len > 0 && isspace(s[len-1])) | 43 | while ( len > 0 && isspace(s[len-1])) |