diff options
author | bug1 <bug1@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2002-11-25 22:31:37 +0000 |
---|---|---|
committer | bug1 <bug1@69ca8d6d-28ef-0310-b511-8ec308f3f277> | 2002-11-25 22:31:37 +0000 |
commit | a6316230a834f51817f8be3da70deed5428eded0 (patch) | |
tree | f2bdc488db3fd9adb8001c80d2d51e769f9b0c78 /libbb | |
parent | 3e04e5d6aec375c308c48d83d8afcdbb7b879c1f (diff) | |
download | busybox-w32-a6316230a834f51817f8be3da70deed5428eded0.tar.gz busybox-w32-a6316230a834f51817f8be3da70deed5428eded0.tar.bz2 busybox-w32-a6316230a834f51817f8be3da70deed5428eded0.zip |
Handle name entries that have a \0 in them, last_patch_65 from Vladimir N. Oleynik
git-svn-id: svn://busybox.net/trunk/busybox@6013 69ca8d6d-28ef-0310-b511-8ec308f3f277
Diffstat (limited to 'libbb')
-rw-r--r-- | libbb/procps.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/libbb/procps.c b/libbb/procps.c index eea6aa681..e76e1ac36 100644 --- a/libbb/procps.c +++ b/libbb/procps.c | |||
@@ -110,10 +110,17 @@ extern procps_status_t * procps_scan(int save_user_arg0) | |||
110 | if(save_user_arg0) { | 110 | if(save_user_arg0) { |
111 | if((fp = fopen(status, "r")) == NULL) | 111 | if((fp = fopen(status, "r")) == NULL) |
112 | continue; | 112 | continue; |
113 | if(fgets(buf, sizeof(buf), fp) != NULL) { | 113 | if((n=fread(buf, 1, sizeof(buf)-1, fp)) > 0) { |
114 | name = strchr(buf, '\n'); | 114 | if(buf[n-1]=='\n') |
115 | if(name != NULL) | 115 | buf[--n] = 0; |
116 | *name = 0; | 116 | name = buf; |
117 | while(n) { | ||
118 | if(*name < ' ') | ||
119 | *name = ' '; | ||
120 | name++; | ||
121 | n--; | ||
122 | } | ||
123 | *name = 0; | ||
117 | if(buf[0]) | 124 | if(buf[0]) |
118 | curstatus.cmd = strdup(buf); | 125 | curstatus.cmd = strdup(buf); |
119 | /* if NULL it work true also */ | 126 | /* if NULL it work true also */ |