Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 30 May 2016 02:59:11 +0000
From:      bugzilla-noreply@freebsd.org
To:        freebsd-bugs@FreeBSD.org
Subject:   [Bug 209850] [patch] units(1) has an incorrect getopt string, causing a segmentation fault when '-o' is used
Message-ID:  <bug-209850-8@https.bugs.freebsd.org/bugzilla/>

next in thread | raw e-mail | index | archive | help
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=3D209850

            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@FreeBSD.org
          Reporter: kdrakehp@zoho.com
          Keywords: patch

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

The 'o' and 'H' options both use 'optarg' while the getopt string states th=
at
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 resul=
t,
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

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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?bug-209850-8>