Found by inspection.
Signed-off-by: Ben Pfaff <blp@nicira.com>
}
for (;;) {
- ssize_t retval = read(netdev->fd, data, size);
- if (retval >= 0) {
+ ssize_t retval = recv(netdev->fd, data, size, MSG_TRUNC);
+ if (retval > size) {
+ /* Received packet was longer than supplied buffer. */
+ return -EMSGSIZE;
+ } else if (retval >= 0) {
return retval;
} else if (errno != EINTR) {
if (errno != EAGAIN) {
* packet, otherwise a negative errno value. Returns -EAGAIN immediately
* if no packet is ready to be received.
*
+ * Returns -EMSGSIZE, and discards the packet, if the received packet is
+ * longer than 'size' bytes.
+ *
* This function can only be expected to return a packet if ->listen() has
* been called successfully.
*