summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksander Morgado <aleksander@aleksander.es>2015-02-24 14:42:21 -0600
committerDan Williams <dcbw@redhat.com>2015-02-24 14:45:45 -0600
commit7f7d17f3867ab2b46f7c95906d49527800e8325b (patch)
tree766ea734c619ac167711db8d887927cd91e70401
parent98412f2f90200f0be286cb09f369df97577a1979 (diff)
libqmi-glib,message: fix big-endian handling of tlv->length (debian #778346)
tlv->length is little-endian, so access to it must be protected with GUINT16_FROM_LE/GUINT16_TO_LE. Fixes testcase failures on PPC32. https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=778346 (cherry picked from commit 33df1d40d02ea453e8b0b31343fc64f185eef479)
-rw-r--r--src/libqmi-glib/qmi-message.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/libqmi-glib/qmi-message.c b/src/libqmi-glib/qmi-message.c
index e31aa4a..c814c15 100644
--- a/src/libqmi-glib/qmi-message.c
+++ b/src/libqmi-glib/qmi-message.c
@@ -1740,7 +1740,7 @@ qmi_message_tlv_read_string (QmiMessage *self,
/* If no length prefix given, read the remaining TLV buffer into a string */
tlv = (struct tlv *) &(self->data[tlv_offset]);
- string_length = (tlv->length - *offset);
+ string_length = (GUINT16_FROM_LE (tlv->length) - *offset);
break;
}
case 1: {
@@ -1837,8 +1837,8 @@ __qmi_message_tlv_read_remaining_size (QmiMessage *self,
tlv = (struct tlv *) &(self->data[tlv_offset]);
- g_warn_if_fail (tlv->length >= offset);
- return (tlv->length >= offset ? (tlv->length - offset) : 0);
+ g_warn_if_fail (GUINT16_FROM_LE (tlv->length) >= offset);
+ return (GUINT16_FROM_LE (tlv->length) >= offset ? (GUINT16_FROM_LE (tlv->length) - offset) : 0);
}
/*****************************************************************************/
@@ -2066,7 +2066,7 @@ get_generic_printable (QmiMessage *self,
line_prefix,
tlv->type,
tlv->value,
- tlv->length);
+ GUINT16_FROM_LE (tlv->length));
g_string_append (printable, printable_tlv);
g_free (printable_tlv);
}