diff options
author | Daniel Willmann <dwillmann@sysmocom.de> | 2021-03-17 16:24:15 +0100 |
---|---|---|
committer | Daniel Willmann <dwillmann@sysmocom.de> | 2021-03-18 14:20:35 +0100 |
commit | 2fa0e9df68ce45d5afa234ccb184b8d76560e1cc (patch) | |
tree | 0037a3afadd1f663e4abab5c42725fe1c947fb20 /include/osmocom | |
parent | d290439b4afe928e7e341540cb92f1abf36a82cb (diff) |
tlv: Fix length returned by t{l16,16l}v_put
Every other function returns a pointer to the first byte after the tlv
that was just written.
tl16v seems to be a copy and paste error from tlv16 above and t16lv seems
to count the 16-bit tag twice.
The new tests verify that the return value of *_put(buf, tag, len, val)
points to buf + *_GROSS_LEN(len).
Change-Id: I268a7e11fb5dce67ce1bd7974ab86c4d2bd002f7
Diffstat (limited to 'include/osmocom')
-rw-r--r-- | include/osmocom/gsm/tlv.h | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/include/osmocom/gsm/tlv.h b/include/osmocom/gsm/tlv.h index dc61de18..7e6dfb5f 100644 --- a/include/osmocom/gsm/tlv.h +++ b/include/osmocom/gsm/tlv.h @@ -148,7 +148,7 @@ static inline uint8_t *tl16v_put(uint8_t *buf, uint8_t tag, uint16_t len, *buf++ = len >> 8; *buf++ = len & 0xff; memcpy(buf, val, len); - return buf + len*2; + return buf + len; } /*! put (append) a TL16 field. */ @@ -168,7 +168,7 @@ static inline uint8_t *t16lv_put(uint8_t *buf, uint16_t tag, uint8_t len, *buf++ = tag & 0xff; *buf++ = len; memcpy(buf, val, len); - return buf + len + 2; + return buf + len; } /*! put (append) a TvLV field */ |