aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorHarald Welte <laforge@osmocom.org>2023-07-18 13:56:10 +0200
committerHarald Welte <laforge@osmocom.org>2023-07-18 13:57:21 +0200
commit06ab6a991f1e2624c8c0490d5430b2cb88d6fb86 (patch)
treed89669ed1067b2d52f1fb93087334216aaaaa924 /src
parentcd813cde137ca6e83986fe05dd3dd30dc8480fd1 (diff)
Check return code of fcntl() in several plaaces
Fixes: CID#307539, CID#307533 Change-Id: I46843174eb4699a59421dc3f3b900a3894c67081
Diffstat (limited to 'src')
-rw-r--r--src/ctl.c13
-rw-r--r--src/proto_clnt.c13
2 files changed, 23 insertions, 3 deletions
diff --git a/src/ctl.c b/src/ctl.c
index 54d37c5..8ed4a69 100644
--- a/src/ctl.c
+++ b/src/ctl.c
@@ -163,9 +163,20 @@ _e1d_ts_start(struct e1_ts *ts, enum e1_ts_mode mode, uint16_t bufsize)
}
int flags = fcntl(ts->fd, F_GETFL);
- fcntl(ts->fd, F_SETFL, flags | O_NONBLOCK);
+ if (flags < 0)
+ goto out_err;
+
+ ret = fcntl(ts->fd, F_SETFL, flags | O_NONBLOCK);
+ if (ret < 0)
+ goto out_err;
return sd[1];
+out_err:
+ close(sd[0]);
+ close(sd[1]);
+ ts->fd = -1;
+ ts->mode = E1_TS_MODE_OFF;
+ return -1;
}
diff --git a/src/proto_clnt.c b/src/proto_clnt.c
index 6c59593..93853e9 100644
--- a/src/proto_clnt.c
+++ b/src/proto_clnt.c
@@ -189,7 +189,12 @@ _e1dp_client_query_base(struct osmo_e1dp_client *clnt,
/* Response */
int flags = fcntl(clnt->ctl_fd.fd, F_GETFL, 0);
- fcntl(clnt->ctl_fd.fd, F_SETFL, flags & ~O_NONBLOCK);
+ if (flags < 0)
+ return -EIO;
+
+ rc = fcntl(clnt->ctl_fd.fd, F_SETFL, flags & ~O_NONBLOCK);
+ if (rc < 0)
+ goto err;
while (1) {
fd = -1;
@@ -207,7 +212,11 @@ _e1dp_client_query_base(struct osmo_e1dp_client *clnt,
msgb_free(msgb);
}
- fcntl(clnt->ctl_fd.fd, F_SETFL, flags);
+ rc = fcntl(clnt->ctl_fd.fd, F_SETFL, flags);
+ if (rc < 0) {
+ rc = -EIO;
+ goto err;
+ }
if (msg_hdr->type != (hdr->type | E1DP_RESP_TYPE)) {
rc = -EPIPE;