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

dexter gerrit-no-reply at lists.osmocom.org
Mon Apr 8 11:44:41 UTC 2019


dexter has submitted this change and it was merged. ( https://gerrit.osmocom.org/13547 )

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

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
---
M src/gsm/gsm_utils.c
1 file changed, 1 insertion(+), 1 deletion(-)

Approvals:
  Vadim Yanitskiy: Looks good to me, approved
  Jenkins Builder: Verified



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: merged
Gerrit-Change-Id: Id24263aa7c9a53544f1639b6ceb09ce5615d5114
Gerrit-Change-Number: 13547
Gerrit-PatchSet: 2
Gerrit-Owner: dexter <pmaier at sysmocom.de>
Gerrit-Reviewer: Jenkins Builder (1000002)
Gerrit-Reviewer: Pau Espin Pedrol <pespin at sysmocom.de>
Gerrit-Reviewer: Vadim Yanitskiy <axilirator at gmail.com>
Gerrit-Reviewer: dexter <pmaier at sysmocom.de>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20190408/9abbb997/attachment.html>


More information about the gerrit-log mailing list