Bug 5876 - Format string bug in procps/ps.c for non-Linux builds
Summary: Format string bug in procps/ps.c for non-Linux builds
Status: RESOLVED FIXED
Alias: None
Product: Busybox
Classification: Unclassified
Component: Other (show other bugs)
Version: unspecified
Hardware: All Other
: P5 minor
Target Milestone: ---
Assignee: unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-01-21 23:48 UTC by Matthias Andree
Modified: 2013-01-24 09:57 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Matthias Andree 2013-01-21 23:48:03 UTC
Compiling this on FreeBSD yields:

  CC      procps/ps.o
procps/ps.c: In function 'get_uptime':
procps/ps.c:86: warning: conversion lacks type at end of format
procps/ps.c:86: warning: too many arguments for format

and indeed the format string is "%l" (ell) - this was probably meant to be "%li", "%ld", "%lx", or "%lo" - please fix.


This would affect versions 1.20.2 and 1.21.0, and I have not checked older versions.

It does not matter much because FreeBSD does not have /proc/uptime, so the function errors out before reaching the bug.  On FreeBSD you get the uptime like this (see src/usr.bin/w/w.c):

 struct timespec tp;
 if (-1 != clock_gettime(CLOCK_MONOTONIC, &tp)) {
   /* process tp here */
 }
Comment 1 Denys Vlasenko 2013-01-24 09:57:36 UTC
Fixed "%l" in git:

commit 6aab061d2d6243505f7c21c7a92dcebc3922784c
Author: Denys Vlasenko <vda.linux@googlemail.com>
Date:   Tue Jan 22 10:07:23 2013 +0100

    ps: fix sscanf format specifier (%l); make uptime unsigned