libosmo-netif[master]: src: _snprintf() helper functions always nul-terminate buffers

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/.

Pau Espin Pedrol gerrit-no-reply at lists.osmocom.org
Sun Sep 10 21:26:16 UTC 2017


Patch Set 1:

> Because I got confused. I remember your original patch is trying to >ensure that we leave room for the nul-termination.

If I recall correctly, it does so in case at some point snprintf returns < 0, in wich case the NUll terminated buffer cannot be ensured.

> Anyway, bottom line is: I don't we need this patch at all.
> Given that snprintf() output is always nul-terminated, the last snprintf() call already guarantees that we deliver a nul-terminated >buffer.

It only guarantees that in case there's no error returned.

What if msg->len == 0? Then we need to null-terminate the buffer.

-- 
To view, visit https://gerrit.osmocom.org/3830
To unsubscribe, visit https://gerrit.osmocom.org/settings

Gerrit-MessageType: comment
Gerrit-Change-Id: I97e517f2d98e83894ea707c63489559302ff6bd2
Gerrit-PatchSet: 1
Gerrit-Project: libosmo-netif
Gerrit-Branch: master
Gerrit-Owner: Pablo Neira Ayuso <pablo at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: Pablo Neira Ayuso <pablo at gnumonks.org>
Gerrit-Reviewer: Pau Espin Pedrol <pespin at sysmocom.de>
Gerrit-HasComments: No



More information about the gerrit-log mailing list