From e8461e486ebac6361b0869962aa86c5b8d46e59e Mon Sep 17 00:00:00 2001 From: Philipp Maier Date: Mon, 8 Apr 2019 12:07:36 +0200 Subject: gsm_utils: fix use buf_len instead of sizeof in osmo_dump_gsmtime_buf The function osmo_dump_gsmtime_buf gets a pointer *buf and a parameter buf_len. The pointer *buf is a string buffer and the function places an \0 at the end of the buffer before it exists. However it uses sizeof(buf) as part of the index calculation, which is incorrect. Lets correct this by using buf_len instead. Change-Id: Id24263aa7c9a53544f1639b6ceb09ce5615d5114 --- src/gsm/gsm_utils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gsm/gsm_utils.c b/src/gsm/gsm_utils.c index f34d9ea5..f2bf57bf 100644 --- a/src/gsm/gsm_utils.c +++ b/src/gsm/gsm_utils.c @@ -890,7 +890,7 @@ char *osmo_dump_gsmtime_buf(char *buf, size_t buf_len, const struct gsm_time *tm { snprintf(buf, buf_len, "%06"PRIu32"/%02"PRIu16"/%02"PRIu8"/%02"PRIu8"/%02"PRIu8, tm->fn, tm->t1, tm->t2, tm->t3, (uint8_t)tm->fn%52); - buf[sizeof(buf)-1] = '\0'; + buf[buf_len-1] = '\0'; return buf; } -- cgit v1.2.3