aboutsummaryrefslogtreecommitdiff
path: root/libbb
diff options
context:
space:
mode:
authorGlenn L McGrath <bug1@ihug.co.nz>2002-11-25 22:31:37 +0000
committerGlenn L McGrath <bug1@ihug.co.nz>2002-11-25 22:31:37 +0000
commit393ad1a834071c441abc5ab55bd3651f1903a842 (patch)
treef2bdc488db3fd9adb8001c80d2d51e769f9b0c78 /libbb
parentbb2e9d47f3c7c8172836b589292612e5f155f054 (diff)
downloadbusybox-393ad1a834071c441abc5ab55bd3651f1903a842.tar.gz
Handle name entries that have a \0 in them, last_patch_65 from Vladimir N. Oleynik
Diffstat (limited to 'libbb')
-rw-r--r--libbb/procps.c15
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)
if(save_user_arg0) {
if((fp = fopen(status, "r")) == NULL)
continue;
- if(fgets(buf, sizeof(buf), fp) != NULL) {
- name = strchr(buf, '\n');
- if(name != NULL)
- *name = 0;
+ if((n=fread(buf, 1, sizeof(buf)-1, fp)) > 0) {
+ if(buf[n-1]=='\n')
+ buf[--n] = 0;
+ name = buf;
+ while(n) {
+ if(*name < ' ')
+ *name = ' ';
+ name++;
+ n--;
+ }
+ *name = 0;
if(buf[0])
curstatus.cmd = strdup(buf);
/* if NULL it work true also */