[PATCH] libosmocore[master]: memleak: gsmtap_sendmsg(): don't return 0 when no data was w...

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

Neels Hofmeyr gerrit-no-reply at lists.osmocom.org
Fri Feb 16 00:36:11 UTC 2018


Review at  https://gerrit.osmocom.org/6513

memleak: gsmtap_sendmsg(): don't return 0 when no data was written

If less than the msgb size was written by write(), we want to return -EIO.
Hence do not return zero when write() wrote zero bytes, return -EIO in that
case as well.

Previously, if write() returned zero, gsmtap_sendmsg() would return zero
*without* freeing the msg, hence neither would the (ideal) caller. So this
fixes a corner-case memleak.

Change-Id: I099ae1c663c018da5db884f7e9d52c45af3ed817
---
M src/gsmtap_util.c
1 file changed, 1 insertion(+), 1 deletion(-)


  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/13/6513/1

diff --git a/src/gsmtap_util.c b/src/gsmtap_util.c
index 8c044b1..962782b 100644
--- a/src/gsmtap_util.c
+++ b/src/gsmtap_util.c
@@ -282,7 +282,7 @@
 		int rc;
 
 		rc = write(gsmtap_inst_fd(gti), msg->data, msg->len);
-		if (rc <= 0) {
+		if (rc < 0) {
 			return rc;
 		} else if (rc >= msg->len) {
 			msgb_free(msg);

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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I099ae1c663c018da5db884f7e9d52c45af3ed817
Gerrit-PatchSet: 1
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Owner: Neels Hofmeyr <nhofmeyr at sysmocom.de>



More information about the gerrit-log mailing list