[Bug 209850] [patch] units(1) has an incorrect getopt string, causing a segmentation fault when '-o' is used

bugzilla-noreply at freebsd.org bugzilla-noreply at freebsd.org
Mon May 30 02:59:11 UTC 2016


https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=209850

            Bug ID: 209850
           Summary: [patch] units(1) has an incorrect getopt string,
                    causing a segmentation fault when '-o' is used
           Product: Base System
           Version: 11.0-CURRENT
          Hardware: Any
                OS: Any
            Status: New
          Keywords: patch
          Severity: Affects Only Me
          Priority: ---
         Component: bin
          Assignee: freebsd-bugs at FreeBSD.org
          Reporter: kdrakehp at zoho.com
          Keywords: patch

Created attachment 170817
  --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=170817&action=edit
Correct the getopt string in usr.bin/units/usits.c

The 'o' and 'H' options both use 'optarg' while the getopt string states that
they do not take an option argument.  When the 'o' option is used the
'output_format' variable is set to the previous value of 'optarg'.  The
'output_format' is used as the format when using printf to output the result,
causing a segmentation fault when it is NULL.


How to reproduce:

printf '\n\n' | units -H m mm

Expected output:
        * 1
        / 1
Output:
        * 1000
        / 0.001


printf '\n\n' | units -o m mm

Expected output:
        * m
        / m
Output:
Segmentation fault

-- 
You are receiving this mail because:
You are the assignee for the bug.


More information about the freebsd-bugs mailing list