If a sequence number larger than the sample control sequence number is
supplied, `nsamples' becomes negative.  Handle this gracefully.

* kern/pc_sample.c (get_sampled_pcs): Handle bogus sequence number.
---
 kern/pc_sample.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/kern/pc_sample.c b/kern/pc_sample.c
index 81b2056..fcb9d71 100644
--- a/kern/pc_sample.c
+++ b/kern/pc_sample.c
@@ -189,6 +189,9 @@ get_sampled_pcs(
                   (sampled_pc_array_t)cp->buffer,
                   (seqidx2 + 1) * sizeof(sampled_pc_t));
        }
+    } else if (nsamples < 0) {
+       /* Bogus SEQNO supplied.  */
+       nsamples = 0;
     } else {
        /*  could either be zero because of overflow, or because
         *  we are being lied to.  In either case, return nothing.
-- 
2.1.3


Reply via email to