Bug 164049 - [patch] getconf(1) returns bad value for ULLONG_MAX
Summary: [patch] getconf(1) returns bad value for ULLONG_MAX
Status: In Progress
Alias: None
Product: Base System
Classification: Unclassified
Component: standards (show other bugs)
Version: unspecified
Hardware: Any Any
: Normal Affects Only Me
Assignee: Garrett Wollman
URL:
Keywords: patch
Depends on:
Blocks:
 
Reported: 2012-01-12 08:50 UTC by Marcus Reid
Modified: 2018-05-23 07:48 UTC (History)
4 users (show)

See Also:
wollman: mfc-stable10+
wollman: mfc-stable11+


Attachments
file.diff (741 bytes, patch)
2012-01-12 08:50 UTC, Marcus Reid
no flags Details | Diff
getconf.patch.txt (779 bytes, patch)
2012-01-16 21:13 UTC, Marcus Reid
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Marcus Reid 2012-01-12 08:50:10 UTC
getconf outputs -1 for ULLONG_MAX (and ULONG_MAX on amd64), which seems strange.  Another implementation that I checked outputs 18446744073709551615 like it should.

Fix: Patch attached.  It creates a couple of compiler warnings but fixes the problem, maybe there is a better way to do it.

Patch attached with submission follows:
How-To-Repeat: getconf ULLONG_MAX
Comment 1 Eitan Adler freebsd_committer freebsd_triage 2012-01-13 04:01:01 UTC
Responsible Changed
From-To: freebsd-standards->eadler

I'll take a look at the affected code. We don't allow compiler warnings 
in our code (except for very good reason) but this could likely be fixed 
correctly :)
Comment 2 Eitan Adler freebsd_committer freebsd_triage 2012-11-08 20:54:36 UTC
Responsible Changed
From-To: eadler->freebsd-bugs

I won't be dealing with this PR for some time, so give it back to the 
pool
Comment 3 Mark Linimon freebsd_committer freebsd_triage 2014-04-20 23:22:26 UTC
Responsible Changed
From-To: freebsd-bugs->freebsd-standards

Canonicalize assignment.
Comment 4 Glenn Weinberg 2018-05-20 06:38:48 UTC
Breaks PMDK test, would be nice to fix this after six years.
Comment 5 commit-hook freebsd_committer 2018-05-23 02:52:24 UTC
A commit references this bug:

Author: wollman
Date: Wed May 23 02:51:58 UTC 2018
New revision: 334070
URL: https://svnweb.freebsd.org/changeset/base/334070

Log:
  Move unsigned limits to a separate table/recognizer and display them
  using the appropriate (unsigned) format specification.  This prevents
  integer overflow when ULLONG_MAX and (on some architectures) ULONG_MAX
  are used to initialize an intmax_t and then displayed as the signed
  value -1.  (A different approach was suggested in the bug report,
  which I did not use.)  If other limits are defined to be unsigned,
  they could be moved here.

  PR:		164049
  Reported by:	Marcus Reid

Changes:
  head/usr.bin/getconf/Makefile
  head/usr.bin/getconf/getconf.c
  head/usr.bin/getconf/getconf.h
  head/usr.bin/getconf/limits.gperf
Comment 6 commit-hook freebsd_committer 2018-05-23 02:55:28 UTC
A commit references this bug:

Author: wollman
Date: Wed May 23 02:54:28 UTC 2018
New revision: 334071
URL: https://svnweb.freebsd.org/changeset/base/334071

Log:
  Whoops, forgot to add this file in r334070.

  PR:		164049

Changes:
  head/usr.bin/getconf/unsigned_limits.gperf
Comment 7 Garrett Wollman freebsd_committer 2018-05-23 03:04:40 UTC
This bug affects every release that has ever had support for ULLONG_MAX in getconf(1), maybe every release ever (I haven't dug through the history enough to see).