Changeset 3621 in MondoRescue for branches/3.3/mindi-busybox/libbb/procps.c


Ignore:
Timestamp:
Dec 20, 2016, 4:07:32 PM (7 years ago)
Author:
Bruno Cornec
Message:

New 3?3 banch for incorporation of latest busybox 1.25. Changing minor version to handle potential incompatibilities.

Location:
branches/3.3
Files:
1 edited
1 copied

Legend:

Unmodified
Added
Removed
  • branches/3.3/mindi-busybox/libbb/procps.c

    r3232 r3621  
    206206        // .....
    207207
    208         char *tp = buf, *p;
     208        char *tp, *p;
    209209
    210210#define SCAN(S, X) \
    211         if (strncmp(tp, S, sizeof(S)-1) == 0) {              \
    212             tp = skip_whitespace(tp + sizeof(S)-1);      \
     211        if ((tp = is_prefixed_with(buf, S)) != NULL) {       \
     212            tp = skip_whitespace(tp);                    \
    213213            total->X += currec.X = fast_strtoul_10(&tp); \
    214214            continue;                                    \
     
    248248            tp = skip_whitespace(skip_fields(tp, 4));
    249249            // filter out /dev/something (something != zero)
    250             if (strncmp(tp, "/dev/", 5) != 0 || strcmp(tp, "/dev/zero\n") == 0) {
     250            if (!is_prefixed_with(tp, "/dev/") || strcmp(tp, "/dev/zero\n") == 0) {
    251251                if (currec.smap_mode[1] == 'w') {
    252252                    currec.mapped_rw = currec.smap_size;
     
    284284#endif
    285285
    286 void BUG_comm_size(void);
    287286procps_status_t* FAST_FUNC procps_scan(procps_status_t* sp, int flags)
    288287{
     
    386385                continue;*/
    387386            cp[0] = '\0';
    388             if (sizeof(sp->comm) < 16)
    389                 BUG_comm_size();
     387            BUILD_BUG_ON(sizeof(sp->comm) < 16);
    390388            comm1 = strchr(buf, '(');
    391389            /*if (comm1)*/
     
    498496                    char *tp;
    499497#define SCAN_TWO(str, name, statement) \
    500     if (strncmp(buf, str, sizeof(str)-1) == 0) { \
    501         tp = skip_whitespace(buf + sizeof(str)-1); \
     498    if ((tp = is_prefixed_with(buf, str)) != NULL) { \
     499        tp = skip_whitespace(tp); \
    502500        sscanf(tp, "%u", &sp->name); \
    503501        statement; \
     
    555553            if (flags & PSSCAN_ARGVN) {
    556554                sp->argv_len = n;
    557                 sp->argv0 = xmalloc(n + 1);
    558                 memcpy(sp->argv0, buf, n + 1);
     555                sp->argv0 = xmemdup(buf, n + 1);
    559556                /* sp->argv0[n] = '\0'; - buf has it */
    560557            } else {
     
    592589            sz--;
    593590        }
     591        if (base[0] == '-') /* "-sh" (login shell)? */
     592            base++;
    594593
    595594        /* If comm differs from argv0, prepend "{comm} ".
    596595         * It allows to see thread names set by prctl(PR_SET_NAME).
    597596         */
    598         if (base[0] == '-') /* "-sh" (login shell)? */
    599             base++;
     597        if (!comm)
     598            return;
    600599        comm_len = strlen(comm);
    601600        /* Why compare up to comm_len, not COMM_LEN-1?
     
    615614            buf[col - 1] = '\0';
    616615        }
    617 
    618616    } else {
    619         snprintf(buf, col, "[%s]", comm);
     617        snprintf(buf, col, "[%s]", comm ? comm : "?");
    620618    }
    621619}
Note: See TracChangeset for help on using the changeset viewer.