aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNeels Hofmeyr <neels@hofmeyr.de>2018-02-16 01:24:03 +0100
committerNeels Hofmeyr <neels@hofmeyr.de>2018-02-16 01:33:35 +0100
commit90539ac30b6201a93b7c4e5b9747e603e64565af (patch)
treed67b278b6191713b1fb879db670febf7a0bc27b1
parentc9a4ce600afc5a11f36c78302f017db9918b4c36 (diff)
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
-rw-r--r--src/gsmtap_util.c2
1 files changed, 1 insertions, 1 deletions
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 gsmtap_sendmsg(struct gsmtap_inst *gti, struct msgb *msg)
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);