X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=src%2Fplugins%2Fsnort%2Fmain.c;h=6b7e49a23adc7cf5c9b746aa63e6c972f5c08ff6;hb=c2810b32cde694a8e245a4f10aa5ce839ad866c7;hp=d05b6310891ce655f53162f82f9193a9f8513213;hpb=70f14ab4875ee078dafe0a038d423983017ec56f;p=vpp.git diff --git a/src/plugins/snort/main.c b/src/plugins/snort/main.c index d05b6310891..6b7e49a23ad 100644 --- a/src/plugins/snort/main.c +++ b/src/plugins/snort/main.c @@ -195,9 +195,18 @@ snort_deq_ready (clib_file_t *uf) snort_per_thread_data_t *ptd = vec_elt_at_index (sm->per_thread_data, vm->thread_index); u64 counter; + ssize_t bytes_read; - if (read (uf->file_descriptor, &counter, sizeof (counter)) < 0) - return clib_error_return (0, "client closed socket"); + bytes_read = read (uf->file_descriptor, &counter, sizeof (counter)); + if (bytes_read < 0) + { + return clib_error_return (0, "client closed socket"); + } + + if (bytes_read < sizeof (counter)) + { + return clib_error_return (0, "unexpected truncated read"); + } clib_interrupt_set (ptd->interrupts, uf->private_data); vlib_node_set_interrupt_pending (vm, snort_deq_node.index);