diff options
| author | Donatas Abraitis <donatas.abraitis@gmail.com> | 2020-04-22 16:16:57 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-04-22 16:16:57 +0300 |
| commit | 0f90b81558b1d37ecd960e487632492fe5f84896 (patch) | |
| tree | 5a78223f4ea51df507cf70fd5abfeb3fe9648de0 /ospfd/ospf_api.c | |
| parent | 79528575901f42f3473bddcae06c0f97125c46be (diff) | |
| parent | e1c511c6944673a9d0bdeceb4b5985b3afe29b1a (diff) | |
Merge pull request #6269 from donaldsharp/coverity_likes_coverity
Coverity likes coverity
Diffstat (limited to 'ospfd/ospf_api.c')
| -rw-r--r-- | ospfd/ospf_api.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/ospfd/ospf_api.c b/ospfd/ospf_api.c index 1ace0977bc..7e7236a3b6 100644 --- a/ospfd/ospf_api.c +++ b/ospfd/ospf_api.c @@ -353,8 +353,8 @@ struct msg *msg_read(int fd) struct msg *msg; struct apimsghdr hdr; uint8_t buf[OSPF_API_MAX_MSG_SIZE]; - int bodylen; - int rlen; + ssize_t bodylen; + ssize_t rlen; /* Read message header */ rlen = readn(fd, (uint8_t *)&hdr, sizeof(struct apimsghdr)); @@ -378,8 +378,13 @@ struct msg *msg_read(int fd) /* Determine body length. */ bodylen = ntohs(hdr.msglen); - if (bodylen > 0) { + if (bodylen > (ssize_t)sizeof(buf)) { + zlog_warn("%s: Body Length of message greater than what we can read", + __func__); + return NULL; + } + if (bodylen > 0) { /* Read message body */ rlen = readn(fd, buf, bodylen); if (rlen < 0) { |
