check for integer overflow in buffer lib (fixes #6217)
authorFlorian Dold <florian.dold@gmail.com>
Fri, 24 Apr 2020 08:20:05 +0000 (13:50 +0530)
committerFlorian Dold <florian.dold@gmail.com>
Fri, 24 Apr 2020 08:20:12 +0000 (13:50 +0530)
src/util/buffer.c

index 8efb3e28451e87c5f8ca5563986476996c88c882..dabf630c7dab027c1189b93cbe7421ede7ce6b78 100644 (file)
@@ -56,6 +56,8 @@ GNUNET_buffer_ensure_remaining (struct GNUNET_Buffer *buf,
 {
   size_t new_capacity = buf->position + n;
 
+  /* guard against overflow */
+  GNUNET_assert (new_capacity >= buf->position);
   if (new_capacity <= buf->capacity)
     return;
   /* warn if calculation of expected size was wrong */