X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=libbb%2Fprocps.c;h=2d2a9665f613088e7bbceb194181d462c654af12;hb=09adaca37d6bd67745c1c81c598ba25006f990b4;hp=9ac5be092274fd7b6580c43f47db8584532baee6;hpb=44608e9693b03661fbab5e27650bb040c6871d11;p=oweals%2Fbusybox.git diff --git a/libbb/procps.c b/libbb/procps.c index 9ac5be092..2d2a9665f 100644 --- a/libbb/procps.c +++ b/libbb/procps.c @@ -8,8 +8,6 @@ * */ -#include "libbb.h" - #if ! defined CONFIG_FEATURE_USE_DEVPS_PATCH #include #include @@ -17,6 +15,7 @@ #include #include +#include "libbb.h" extern procps_status_t * procps_scan(int save_user_arg0) { @@ -111,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(((unsigned char)*name) < ' ') + *name = ' '; + name++; + n--; + } + *name = 0; if(buf[0]) curstatus.cmd = strdup(buf); /* if NULL it work true also */