diff --git a/NEWS b/NEWS index 0ff69ccb..06541e88 100644 --- a/NEWS +++ b/NEWS @@ -5,6 +5,7 @@ procps-ng-NEXT * library: dont use SIGPWR on FreeBSD Debian #832148 * pmap: fix duplicate output line under '-x' option Redhat #1374061 * top: eliminated minor libnuma memory leak + * ps: avoid eip/esp address truncations Debain #846361 procps-ng-3.3.12 ---------------- diff --git a/ps/output.c b/ps/output.c index bf5cc892..304beebf 100644 --- a/ps/output.c +++ b/ps/output.c @@ -719,17 +719,17 @@ tsiz text size (in Kbytes) static int pr_stackp(char *restrict const outbuf, const proc_t *restrict const pp){ setREL1(ADDR_START_STACK) - return snprintf(outbuf, COLWID, "%08x", (unsigned)(rSv(ADDR_START_STACK, ul_int, pp))); + return snprintf(outbuf, COLWID, "%0*lx", (int)(2*sizeof(long)), rSv(ADDR_START_STACK, ul_int, pp)); } static int pr_esp(char *restrict const outbuf, const proc_t *restrict const pp){ setREL1(ADDR_KSTK_ESP) - return snprintf(outbuf, COLWID, "%08x", (unsigned)(rSv(ADDR_KSTK_ESP, ul_int, pp))); + return snprintf(outbuf, COLWID, "%0*lx", (int)(2*sizeof(long)), rSv(ADDR_KSTK_ESP, ul_int, pp)); } static int pr_eip(char *restrict const outbuf, const proc_t *restrict const pp){ setREL1(ADDR_KSTK_EIP) - return snprintf(outbuf, COLWID, "%08x", (unsigned)(rSv(ADDR_KSTK_EIP, ul_int, pp))); + return snprintf(outbuf, COLWID, "%0*lx", (int)(2*sizeof(long)), rSv(ADDR_KSTK_EIP, ul_int, pp)); } static int pr_bsdtime(char *restrict const outbuf, const proc_t *restrict const pp){ @@ -1380,11 +1380,11 @@ static const format_struct format_array[] = { /* {"dsiz", "DSIZ", pr_dsiz, PIDS_VSIZE_PGS, 4, LNX, PO|RIGHT}, {"egid", "EGID", pr_egid, PIDS_ID_EGID, 5, LNX, ET|RIGHT}, {"egroup", "EGROUP", pr_egroup, PIDS_ID_EGROUP, 8, LNX, ET|USER}, -{"eip", "EIP", pr_eip, PIDS_ADDR_KSTK_EIP, 8, LNX, TO|RIGHT}, +{"eip", "EIP", pr_eip, PIDS_ADDR_KSTK_EIP, (int)(2*sizeof(long)), LNX, TO|RIGHT}, {"emul", "EMUL", pr_nop, PIDS_noop, 13, BSD, PO|LEFT}, /* "FreeBSD ELF32" and such */ -{"end_code", "E_CODE", pr_nop, PIDS_ADDR_END_CODE, 8, LNx, PO|RIGHT}, +{"end_code", "E_CODE", pr_nop, PIDS_ADDR_END_CODE, (int)(2*sizeof(long)), LNx, PO|RIGHT}, // sortable, but unprintable ?? {"environ","ENVIRONMENT",pr_nop, PIDS_noop, 11, LNx, PO|UNLIMITED}, -{"esp", "ESP", pr_esp, PIDS_ADDR_KSTK_ESP, 8, LNX, TO|RIGHT}, +{"esp", "ESP", pr_esp, PIDS_ADDR_KSTK_ESP, (int)(2*sizeof(long)), LNX, TO|RIGHT}, {"etime", "ELAPSED", pr_etime, PIDS_TIME_ELAPSED, 11, U98, ET|RIGHT}, /* was 7 wide */ {"etimes", "ELAPSED", pr_etimes, PIDS_TIME_ELAPSED, 7, BSD, ET|RIGHT}, /* FreeBSD */ {"euid", "EUID", pr_euid, PIDS_ID_EUID, 5, LNX, ET|RIGHT}, @@ -1518,10 +1518,10 @@ static const format_struct format_array[] = { /* {"sl", "SL", pr_nop, PIDS_noop, 3, XXX, AN|RIGHT}, {"slice", "SLICE", pr_sd_slice, PIDS_SD_SLICE, 31, LNX, ET|LEFT}, {"spid", "SPID", pr_tasks, PIDS_ID_PID, 5, SGI, TO|PIDMAX|RIGHT}, -{"stackp", "STACKP", pr_stackp, PIDS_ADDR_START_STACK, 8, LNX, PO|RIGHT}, /*start_stack*/ +{"stackp", "STACKP", pr_stackp, PIDS_ADDR_START_STACK, (int)(2*sizeof(long)), LNX, PO|RIGHT}, /*start_stack*/ {"start", "STARTED", pr_start, PIDS_TIME_START, 8, XXX, ET|RIGHT}, -{"start_code", "S_CODE", pr_nop, PIDS_noop, 8, LNx, PO|RIGHT}, -{"start_stack", "STACKP", pr_stackp, PIDS_ADDR_START_STACK, 8, LNX, PO|RIGHT}, /*stackp*/ +{"start_code", "S_CODE", pr_nop, PIDS_ADDR_START_CODE, (int)(2*sizeof(long)), LNx, PO|RIGHT}, // sortable, but unprintable ?? +{"start_stack", "STACKP",pr_stackp, PIDS_ADDR_START_STACK, (int)(2*sizeof(long)), LNX, PO|RIGHT}, /*stackp*/ {"start_time", "START", pr_stime, PIDS_TIME_START, 5, LNx, ET|RIGHT}, {"stat", "STAT", pr_stat, PIDS_STATE, 4, BSD, TO|LEFT}, /*state,s*/ {"state", "S", pr_s, PIDS_STATE, 1, XXX, TO|LEFT}, /*stat,s*/ /* was STAT */