OSDN Git Service

attrib: Allow dec_read_resp() to just check if PDU is valid
authorAnderson Lizardo <anderson.lizardo@openbossa.org>
Fri, 19 Jul 2013 17:34:16 +0000 (13:34 -0400)
committerJohan Hedberg <johan.hedberg@intel.com>
Wed, 24 Jul 2013 15:43:17 +0000 (08:43 -0700)
If a NULL "value" parameter is given, only check whether PDU is valid,
without copying attribute value to a buffer.

attrib/att.c

index d5f4f68..753c753 100644 (file)
@@ -704,12 +704,12 @@ ssize_t dec_read_resp(const uint8_t *pdu, size_t len, uint8_t *value,
        if (pdu == NULL)
                return -EINVAL;
 
-       if (value == NULL)
-               return -EINVAL;
-
        if (pdu[0] != ATT_OP_READ_RESP)
                return -EINVAL;
 
+       if (value == NULL)
+               return len - 1;
+
        if (vlen < (len - 1))
                return -ENOBUFS;