Skip to contentSkip to conversation

genl: Fix size calculation in msg_grow

PATCH Applied Andrew Zaborowski 2 participants 2 messages Oct 22, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 genl: Fix size calculation in msg_grow

"msg->size - needed" was the opposite of the value we actually need and could end up being negative if we were appending an attribute larger than the current message size.

---
 ell/genl.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
ell/genl.c +1 -1
index 1260020..6177fd5 100644
@@ -755,7 +755,7 @@ static bool msg_grow(struct l_genl_msg *msg, uint32_t needed)
 	if (msg->size >= msg->len + needed)
 		return true;
 
-	grow_by = msg->size - needed;
+	grow_by = msg->len + needed - msg->size;
 
 	if (grow_by < 32)
 		grow_by = 128;
Signature · 1 line
2.20.1
#1 lore raw

Hi Andrew,

Quoted 7 lines · Andrew Zaborowski

"msg->size - needed" was the opposite of the value we actually need and could end up being negative if we were appending an attribute larger than the current message size.

---
  ell/genl.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

applied, thanks.

Regards,
-Denis