fixeria has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmocore/+/27005 )
Change subject: gsm_utils: use talloc API in gsm_7bit_encode_n() ......................................................................
gsm_utils: use talloc API in gsm_7bit_encode_n()
Unfortunately, in this case we cannot make any assumptions on the maximum size of the input string, so we cannot allocate the buffer on the stack. Let's at least use talloc API.
Change-Id: I8a38c493eff25b4f16af1740a1bcecb5098673d9 --- M src/gsm/gsm_utils.c 1 file changed, 2 insertions(+), 2 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/05/27005/1
diff --git a/src/gsm/gsm_utils.c b/src/gsm/gsm_utils.c index ba24291..511de79 100644 --- a/src/gsm/gsm_utils.c +++ b/src/gsm/gsm_utils.c @@ -382,7 +382,7 @@ size_t max_septets = n * 8 / 7;
/* prepare for the worst case, every character expanding to two bytes */ - uint8_t *rdata = calloc(strlen(data) * 2, sizeof(uint8_t)); + uint8_t *rdata = talloc_zero(OTC_GLOBAL, strlen(data) * 2); y = gsm_septet_encode(rdata, data);
if (y > max_septets) { @@ -398,7 +398,7 @@ if (octets) *octets = o;
- free(rdata); + talloc_free(rdata);
/* * We don't care about the number of octets, because they are not