Message ID | 20170817132614.17160-1-christian.storm@siemens.com |
---|---|
State | Accepted |
Delegated to: | Stefano Babic |
Headers | show |
On 17/08/2017 15:26, Christian Storm wrote: > When signaling the due execution of postupdate() via > ipc_postupdate(), zero out msg preserving msg.data.instmsg.buf > so that an optional message can be forwarded to postupdate(). > > Signed-off-by: Christian Storm <christian.storm@siemens.com> > --- > ipc/network_ipc.c | 14 ++++++++++++++ > 1 file changed, 14 insertions(+) > > diff --git a/ipc/network_ipc.c b/ipc/network_ipc.c > index 0f346ba..6629461 100644 > --- a/ipc/network_ipc.c > +++ b/ipc/network_ipc.c > @@ -78,7 +78,21 @@ int ipc_postupdate(ipc_message *msg) { > } > > ssize_t ret; > + char* tmpbuf = NULL; > + if (msg->data.instmsg.len > 0) { > + if ((tmpbuf = strndupa(msg->data.instmsg.buf, > + msg->data.instmsg.len > sizeof(msg->data.instmsg.buf) > + ? sizeof(msg->data.instmsg.buf) > + : msg->data.instmsg.len)) == NULL) { > + close(connfd); > + return -1; > + } > + } > memset(msg, 0, sizeof(*msg)); > + if (tmpbuf != NULL) { > + strncpy(msg->data.instmsg.buf, tmpbuf, sizeof(msg->data.instmsg.buf)); > + msg->data.instmsg.len = strnlen(tmpbuf, sizeof(msg->data.instmsg.buf)); > + } > msg->magic = IPC_MAGIC; > msg->type = POST_UPDATE; > ret = write(connfd, msg, sizeof(*msg)); > Applied to -master, thanks ! Best regards, Stefano Babic
diff --git a/ipc/network_ipc.c b/ipc/network_ipc.c index 0f346ba..6629461 100644 --- a/ipc/network_ipc.c +++ b/ipc/network_ipc.c @@ -78,7 +78,21 @@ int ipc_postupdate(ipc_message *msg) { } ssize_t ret; + char* tmpbuf = NULL; + if (msg->data.instmsg.len > 0) { + if ((tmpbuf = strndupa(msg->data.instmsg.buf, + msg->data.instmsg.len > sizeof(msg->data.instmsg.buf) + ? sizeof(msg->data.instmsg.buf) + : msg->data.instmsg.len)) == NULL) { + close(connfd); + return -1; + } + } memset(msg, 0, sizeof(*msg)); + if (tmpbuf != NULL) { + strncpy(msg->data.instmsg.buf, tmpbuf, sizeof(msg->data.instmsg.buf)); + msg->data.instmsg.len = strnlen(tmpbuf, sizeof(msg->data.instmsg.buf)); + } msg->magic = IPC_MAGIC; msg->type = POST_UPDATE; ret = write(connfd, msg, sizeof(*msg));
When signaling the due execution of postupdate() via ipc_postupdate(), zero out msg preserving msg.data.instmsg.buf so that an optional message can be forwarded to postupdate(). Signed-off-by: Christian Storm <christian.storm@siemens.com> --- ipc/network_ipc.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+)