gsm_04_80: Use the return value of gsm_7bit_encode as length
Use the idiom msgb_put(msg, 0) to get the data pointer, then
encode the string into the msgb and then adjust the size.
diff --git a/openbsc/src/gsm_04_80.c b/openbsc/src/gsm_04_80.c
index 71fb405..2d061e3 100644
--- a/openbsc/src/gsm_04_80.c
+++ b/openbsc/src/gsm_04_80.c
@@ -318,13 +318,10 @@
u_int8_t *ptr8;
int response_len;
- response_len = (strlen(response_text) * 7) / 8;
- if (((strlen(response_text) * 7) % 8) != 0)
- response_len += 1;
-
/* First put the payload text into the message */
- ptr8 = msgb_put(msg, response_len);
- gsm_7bit_encode(ptr8, response_text);
+ ptr8 = msgb_put(msg, 0);
+ response_len = gsm_7bit_encode(ptr8, response_text);
+ msgb_put(msg, response_len);
/* Then wrap it as an Octet String */
msgb_wrap_with_TL(msg, ASN1_OCTET_STRING_TAG);