summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorQuentin Young <qlyoung@cumulusnetworks.com>2018-01-03 19:58:53 +0100
committerQuentin Young <qlyoung@cumulusnetworks.com>2018-01-03 20:04:43 +0100
commit74e4a329a34b1d1ad5e3ee5653ae3b7f0680c9fe (patch)
treef7ec930d50ab493f46bd4d8a2665b9ac8ab5b2d1 /tests
parentlib: add ringbuf_copy() (diff)
downloadfrr-74e4a329a34b1d1ad5e3ee5653ae3b7f0680c9fe.tar.xz
frr-74e4a329a34b1d1ad5e3ee5653ae3b7f0680c9fe.zip
lib: fix a few bugs in ring buffers
* Fix rare failure caused when end pointer is at end of buffer memory and a call to ringbuf_get() is made that reads all of the data in the buffer; start pointer was advanced past end pointer, causing some special handling to be skipped * Fix ringbuf_peek() moving start pointer * Fix use after free * Remove extraneous assignment * Update relevant tests Signed-off-by: Quentin Young <qlyoung@cumulusnetworks.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/lib/test_ringbuf.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/tests/lib/test_ringbuf.c b/tests/lib/test_ringbuf.c
index c2f4f76a6..7ba5a29b6 100644
--- a/tests/lib/test_ringbuf.c
+++ b/tests/lib/test_ringbuf.c
@@ -65,7 +65,7 @@ int main(int argc, char **argv)
validate_state(soil, BUFSIZ, BUFSIZ);
assert(soil->start == 0);
- assert(soil->end == BUFSIZ);
+ assert(soil->end == 0);
/* read 15 bytes of garbage */
printf("Validating read...\n");
@@ -73,7 +73,7 @@ int main(int argc, char **argv)
validate_state(soil, BUFSIZ, BUFSIZ - 15);
assert(soil->start == 15);
- assert(soil->end == BUFSIZ);
+ assert(soil->end == 0);
/* put another 10 bytes and validate wraparound */
printf("Validating wraparound...\n");