Skip to contentSkip to conversation

asn1: fix use-after-free in asn1_write

PATCH New Jeff Layton 1 participant 1 message Oct 14, 2013

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 asn1: fix use-after-free in asn1_write

If the talloc_realloc() fails, asn1_write calls talloc_free on the context and then immediately dereferences the pointer.

Fix this by skipping the talloc_free here. Let the caller handle it.

---
 asn1.c | 1 -
 1 file changed, 1 deletion(-)
asn1.c +0 -1
index ea50a23..4c0e480 100644
@@ -47,7 +47,6 @@ bool asn1_write(struct asn1_data *data, const void *p, int len)
 		uint8_t *newp;
 		newp = talloc_realloc(data, data->data, uint8_t, data->ofs+len);
 		if (!newp) {
-			asn1_free(data);
 			data->has_error = true;
 			return false;
 		}
Signature · 1 line
1.8.3.1