Browse Source

Add more assertions

Christoph Biedl 4 years ago
parent
commit
8076ae421a
2 changed files with 32 additions and 0 deletions
  1. 31 0
      debian/patches/add-assertions.patch
  2. 1 0
      debian/patches/series

+ 31 - 0
debian/patches/add-assertions.patch

@@ -0,0 +1,31 @@
+Description: Add assertion checks where appropriate
+Author: Christoph Biedl <debian.axhn@manchmal.in-ulm.de>
+Bug: https://bitbucket.org/ripencc/bgpdump/issues/37/
+Last-Update: 2016-07-23
+
+--- a/bgpdump_lib.c
++++ b/bgpdump_lib.c
+@@ -184,6 +184,7 @@
+     dump->parsed++;
+     this_entry->attr=NULL;
+ 
++    assert(this_entry->length);
+     buffer = malloc_check(this_entry->length);
+     bytes_read = cfr_read_n(dump->f, buffer, this_entry->length);
+     if(bytes_read != this_entry->length) {
+@@ -536,6 +537,7 @@
+ 		e = &prefixdata->entries[i];
+ 
+ 		mstream_getw(s, &e->peer_index);
++		assert (table_dump_v2_peer_index_table);
+ 		e->peer = &table_dump_v2_peer_index_table->entries[e->peer_index];
+ 		mstream_getl(s, &e->originated_time);
+             
+@@ -574,6 +576,7 @@
+ 		e = &prefixdata->entries[i];
+ 
+ 		mstream_getw(s, &e->peer_index);
++		assert (table_dump_v2_peer_index_table);
+ 		e->peer = &table_dump_v2_peer_index_table->entries[e->peer_index];
+ 		mstream_getl(s, &e->originated_time);
+ 

+ 1 - 0
debian/patches/series

@@ -14,6 +14,7 @@ fix-gzfile-type-usage.patch
 fix-sprintf-append.patch
 use-strlcat.patch
 fix-getopt-usage.patch
+add-assertions.patch
 
 # features
 increase-max-prefixes.patch