Change in libosmocore[master]: gsm_utils: fix use buf_len instead of sizeof() osmo_dump_gsmtime_buf

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

dexter gerrit-no-reply at lists.osmocom.org
Mon Apr 8 10:12:13 UTC 2019


dexter has uploaded this change for review. ( https://gerrit.osmocom.org/13547


Change subject: gsm_utils: fix use buf_len instead of sizeof() osmo_dump_gsmtime_buf
......................................................................

gsm_utils: fix use buf_len instead of sizeof() 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
---
M src/gsm/gsm_utils.c
1 file changed, 1 insertion(+), 1 deletion(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/47/13547/1

diff --git a/src/gsm/gsm_utils.c b/src/gsm/gsm_utils.c
index f34d9ea..f2bf57b 100644
--- a/src/gsm/gsm_utils.c
+++ b/src/gsm/gsm_utils.c
@@ -890,7 +890,7 @@
 {
 	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;
 }
 

-- 
To view, visit https://gerrit.osmocom.org/13547
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: Id24263aa7c9a53544f1639b6ceb09ce5615d5114
Gerrit-Change-Number: 13547
Gerrit-PatchSet: 1
Gerrit-Owner: dexter <pmaier at sysmocom.de>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190408/36de258d/attachment.htm>


More information about the gerrit-log mailing list