Enable FORTIFY and FORMAT SECURITY compile flags

1. Enable below 2 defenses in Makefile
   "-O2 -D_FORTIFY_SOURCE=2"
   "-Wformat -Wformat-security"

2. Update related source code impacted by above 2 flags

Change-Id: Ib42214848f030b4cf508cd7c52a7e3cc809435d9
Signed-off-by: Yonghua Huang <yonghua.huang@intel.com>
This commit is contained in:
Yonghua Huang
2018-03-13 17:02:51 +08:00
committed by Jack Ren
parent 155be81dbf
commit b6d73be1a6
9 changed files with 81 additions and 37 deletions

View File

@@ -280,6 +280,7 @@ virtio_net_tap_tx(struct virtio_net *net, struct iovec *iov, int iovcnt,
int len)
{
static char pad[60]; /* all zero bytes */
ssize_t ret;
if (net->tapfd == -1)
return;
@@ -294,7 +295,8 @@ virtio_net_tap_tx(struct virtio_net *net, struct iovec *iov, int iovcnt,
iov[iovcnt].iov_len = 60 - len;
iovcnt++;
}
(void) writev(net->tapfd, iov, iovcnt);
ret = writev(net->tapfd, iov, iovcnt);
(void)ret; /*avoid compiler warning*/
}
/*
@@ -335,6 +337,7 @@ virtio_net_tap_rx(struct virtio_net *net)
void *vrx;
int len, n;
uint16_t idx;
ssize_t ret;
/*
* Should never be called without a valid tap fd
@@ -349,7 +352,9 @@ virtio_net_tap_rx(struct virtio_net *net)
/*
* Drop the packet and try later.
*/
(void) read(net->tapfd, dummybuf, sizeof(dummybuf));
ret = read(net->tapfd, dummybuf, sizeof(dummybuf));
(void)ret; /*avoid compiler warning*/
return;
}
@@ -362,7 +367,9 @@ virtio_net_tap_rx(struct virtio_net *net)
* Drop the packet and try later. Interrupt on
* empty, if that's negotiated.
*/
(void) read(net->tapfd, dummybuf, sizeof(dummybuf));
ret = read(net->tapfd, dummybuf, sizeof(dummybuf));
(void)ret; /*avoid compiler warning*/
vq_endchains(vq, 1);
return;
}