aboutsummaryrefslogtreecommitdiffstats
path: root/src/gsm/gsm_utils.c
diff options
context:
space:
mode:
authorPhilipp Maier <pmaier@sysmocom.de>2019-04-08 12:07:36 +0200
committerPhilipp Maier <pmaier@sysmocom.de>2019-04-08 12:16:03 +0200
commite8461e486ebac6361b0869962aa86c5b8d46e59e (patch)
treeee0d2e034b148fe5c2bb8ed65985d33e509abe73 /src/gsm/gsm_utils.c
parent4a62eda225ab7f3c9556990c81a6fc5e19b5eec8 (diff)
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
Diffstat (limited to 'src/gsm/gsm_utils.c')
-rw-r--r--src/gsm/gsm_utils.c2
1 files changed, 1 insertions, 1 deletions
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;
}