Skip to contentSkip to conversation

consume: avoid a bad prid causing a core dump

PATCH In review Kris Van Hees 2 participants 2 messages Mar 21, 2025

lore
Share & tools
lore
#0 lore raw

PATCH 2/2 consume: avoid a bad prid causing a core dump

We were not guarding against prid being DTACE_IDNONE (0), which would cause a core dump if it was encountered in a trace record.

---
 libdtrace/dt_consume.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
libdtrace/dt_consume.c +1 -1
index 58a2ead9..ed52b88b 100644
@@ -2191,7 +2191,7 @@ dt_consume_one_probe(dtrace_hdl_t *dtp, FILE *fp, char *data, uint32_t size,
 	pdat->dtpda_stid = stid;
 	pdat->dtpda_data = data;
 
-	if (prid >= dtp->dt_probe_id)
+	if (prid >= dtp->dt_probe_id || prid == DTRACE_IDNONE)
 		return dt_set_errno(dtp, EDT_BADID);
 	pdat->dtpda_pdesc = (dtrace_probedesc_t *)dtp->dt_probes[prid]->desc;
 	if (dt_stid_lookup(dtp, stid, &pdat->dtpda_ddesc) != 0)
Signature · 1 line
2.45.2
Reviewed-by on v1 2/2
#1 lore raw
Quoted 2 lines · Kris Van Hees via DTrace-devel

We were not guarding against prid being DTACE_IDNONE (0), which would cause a core dump if it was encountered in a trace record.

... hm, I had no idea that the dt_probes array was 1-based, but I guess given that the NONE id is 0 it kind of has to be.

Quoted 1 line