[Bug 237263] [patch] hexdump(1) crashes on invalid format strings without a conversion character after "%"

bugzilla-noreply at freebsd.org bugzilla-noreply at freebsd.org
Sat Apr 13 15:50:44 UTC 2019


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

            Bug ID: 237263
           Summary: [patch] hexdump(1) crashes on invalid format strings
                    without a conversion character after "%"
           Product: Base System
           Version: CURRENT
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Only Me
          Priority: ---
         Component: bin
          Assignee: bugs at FreeBSD.org
          Reporter: bojan_petrovic at fastmail.fm

Created attachment 203645
  --> https://bugs.freebsd.org/bugzilla/attachment.cgi?id=203645&action=edit
hexdump patch fixing missing conversion char crashes

Hexdump can segfault if format contains a '%' at the end, without a
conversion specifier. 

Examples:

  hexdump -e '"%"'
  hexdump -e '4/2 "%"'
  hexdump -e '"%53"'


I believe this happens because the behavior of "strchr" on '\0' is not
handled when a conversion specifier is scanned: "The terminating null
byte is considered part of the string, so that if c is specified  as
'\0', these functions return a pointer to the terminator."

I've attached a possible fix (with a test) which treats missing
conversion characters as a format errors.

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


More information about the freebsd-bugs mailing list