Check return code of fcntl() in several plaaces

Fixes: CID#307539, CID#307533
Change-Id: I46843174eb4699a59421dc3f3b900a3894c67081
This commit is contained in:
Harald Welte 2023-07-18 13:56:10 +02:00
parent cd813cde13
commit 06ab6a991f
2 changed files with 23 additions and 3 deletions

View File

@ -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;
}

View File

@ -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;