smsutil: Fix uninitialized optional elements
authorDenis Kenzior <denkenz@gmail.com>
Thu, 2 Dec 2010 13:53:54 +0000 (07:53 -0600)
committerDenis Kenzior <denkenz@gmail.com>
Thu, 2 Dec 2010 13:53:54 +0000 (07:53 -0600)
sms_decode was never memsetting the returned structure, so if any
optional elements were present in the SMS (e.g. status report) then the
structure was not completely initialized.

src/smsutil.c

index b06e9bf..631d949 100644 (file)
@@ -1024,8 +1024,6 @@ static gboolean decode_status_report(const unsigned char *pdu, int len,
        if (out->status_report.pi & 0x02) {
                if (!next_octet(pdu, len, &offset, &out->status_report.dcs))
                        return FALSE;
-       } else {
-               out->status_report.dcs = 0;
        }
 
        if (out->status_report.pi & 0x04) {
@@ -1509,6 +1507,8 @@ gboolean sms_decode(const unsigned char *pdu, int len, gboolean outgoing,
        if (len == 0)
                return FALSE;
 
+       memset(out, 0, sizeof(*out));
+
        if (tpdu_len < len) {
                if (!sms_decode_address_field(pdu, len, &offset,
                                                TRUE, &out->sc_addr))