Skip to content
Snippets Groups Projects
  1. May 22, 2019
    • Markus Armbruster's avatar
      cutils: Simplify how parse_uint() checks for whitespace · db3d11ee
      Markus Armbruster authored
      
      Use qemu_isspace() so we don't have to cast to unsigned char.
      
      Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
      Message-Id: <20190514180311.16028-7-armbru@redhat.com>
      Reviewed-by: default avatarPhilippe Mathieu-Daudé <philmd@redhat.com>
      db3d11ee
    • Markus Armbruster's avatar
      gdbstub: Fix misuse of isxdigit() · 33c846ef
      Markus Armbruster authored
      
      gdb_read_byte() passes its @ch argument to isxdigit().  Undefined
      behavior when the value is negative.  Two callers:
      
      * gdb_chr_receive() passes an uint8_t value.  Safe.
      
      * gdb_handlesig() a char value.  Unsafe.  Not a security issue,
        because the characters come from the gdb client, which is trusted.
      
      The obvious fix would be casting @ch to unsigned char.  But note that
      gdb_read_byte() already casts @ch to uint8_t in many places.  Uses of
      @ch without such a cast:
      
      (1) Compare to a character constant with == or !=
      
      (2) s->linesum += ch
      
      (3) Store ch or ch ^ 0x20 into s->line_buf[]
      
      (4) Check for invalid RLE count:
          ch < ' ' || ch == '#' || ch == '$' || ch > 126
      
      (5) Pass to isxdigit()
      
      (6) Pass to fromhex()
      
      Change the parameter type from int to uint8_t, and drop the now
      redundant casts.  Affects the above uses as follows:
      
      (1) No change: the character constants are all non-negative.
      
      (2) Effectively no change: we only ever use s->linesum & 0xff, and
          s->linesum is int.
      
      (3) No change: s->line_buf[] is char[].
      
      (4) No change.
      
      (5) Avoid undefined behavior.
      
      (6) No change: only reached when isxdigit(ch)
      
      Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
      Message-Id: <20190514180311.16028-5-armbru@redhat.com>
      33c846ef
    • Markus Armbruster's avatar
      gdbstub: Reject invalid RLE repeat counts · 046aba16
      Markus Armbruster authored
      
      "Debugging with GDB / Appendix E GDB Remote Serial Protocol /
      Overview" specifies "The printable characters '#' and '$' or with a
      numeric value greater than 126 must not be used."  gdb_read_byte()
      only rejects values < 32.  This is wrong.  Impact depends on the caller:
      
      * gdb_handlesig() passes a char.  Incorrectly accepts '#', '$' and
        '\127'.
      
      * gdb_chr_receive() passes an uint8_t.  Additionally accepts
        characters with the most-significant bit set.
      
      Correct the validity check to match the specification.
      
      Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
      Reviewed-by: default avatarPhilippe Mathieu-Daudé <philmd@redhat.com>
      Message-Id: <20190514180311.16028-4-armbru@redhat.com>
      046aba16
    • Markus Armbruster's avatar
      tests/vhost-user-bridge: Fix misuse of isdigit() · d18dc3af
      Markus Armbruster authored
      
      vubr_set_host() passes char values to isdigit().  Undefined behavior
      when the value is negative.
      
      Fix by using qemu_isdigit() instead.
      
      Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
      Message-Id: <20190514180311.16028-3-armbru@redhat.com>
      Reviewed-by: default avatarPhilippe Mathieu-Daudé <philmd@redhat.com>
      Reviewed-by: default avatarThomas Huth <thuth@redhat.com>
      [Missing #include "qemu-common.h" fixed]
      d18dc3af
    • Markus Armbruster's avatar
      qemu-bridge-helper: Fix misuse of isspace() · b8c3511d
      Markus Armbruster authored
      
      parse_acl_file() passes char values to isspace().  Undefined behavior
      when the value is negative.  Not a security issue, because the
      characters come from trusted $prefix/etc/qemu/bridge.conf and the
      files it includes.
      
      Furthermore, isspace()'s locale-dependence means qemu-bridge-helper
      uses the user's locale for parsing $prefix/etc/bridge.conf.  Feels
      wrong.
      
      Use g_ascii_isspace() instead.  This fixes the undefined behavior, and
      makes parsing of $prefix/etc/bridge.conf locale-independent.
      
      Signed-off-by: default avatarMarkus Armbruster <armbru@redhat.com>
      Message-Id: <20190514180311.16028-2-armbru@redhat.com>
      b8c3511d
  2. May 21, 2019
  3. May 20, 2019
Loading