[gnome-boxes] get_decoded_udev_property: Fix sscanf use



commit e3aaeedeaa445ab055d273c64be42e616f9928af
Author: Christophe Fergeau <cfergeau redhat com>
Date:   Wed Mar 12 15:55:17 2014 +0100

    get_decoded_udev_property: Fix sscanf use
    
    sscanf man page says about %x:
    'x      Matches an unsigned hexadecimal integer; the next pointer must be a
    pointer to unsigned int'
    get_decoded_udev_property() is using %02x, but this is not documented as
    reducing the size of the expected pointer, it's only documented as causing
    sscanf to read at most 2 digits of the parsed number.
    
    Boxes was passing an uint8 to scanf instead of an uint, causing memory
    corruption (plus a 'fortify: stack smashing detected' message if this is
    enabled when building), and eventually a crash in get_decoded_udev_property().

 src/installer-media.vala |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
---
diff --git a/src/installer-media.vala b/src/installer-media.vala
index f638669..30b0ca2 100644
--- a/src/installer-media.vala
+++ b/src/installer-media.vala
@@ -234,7 +234,7 @@ private class Boxes.InstallerMedia : GLib.Object {
 
         var decoded = "";
         for (var i = 0; i < encoded.length; ) {
-           uint8 x;
+           uint x;
 
            if (encoded[i:encoded.length].scanf ("\\x%02x", out x) > 0) {
                decoded += ((char) x).to_string ();


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]