]> git.ipfire.org Git - thirdparty/nftables.git/commitdiff
erec: Sanitize erec location indesc
authorPhil Sutter <phil@nwl.cc>
Tue, 26 Jan 2021 17:52:15 +0000 (18:52 +0100)
committerPhil Sutter <phil@nwl.cc>
Tue, 9 Feb 2021 16:00:09 +0000 (17:00 +0100)
erec_print() unconditionally dereferences erec->locations->indesc, so
make sure it is valid when either creating an erec or adding a location.

Signed-off-by: Phil Sutter <phil@nwl.cc>
src/erec.c

index c550a596b38c83a52eb410c166a27594e3737dff..5c3351a512464af3c7470098f7f072599a195afc 100644 (file)
@@ -38,7 +38,8 @@ void erec_add_location(struct error_record *erec, const struct location *loc)
 {
        assert(erec->num_locations < EREC_LOCATIONS_MAX);
        erec->locations[erec->num_locations] = *loc;
-       erec->locations[erec->num_locations].indesc = loc->indesc;
+       erec->locations[erec->num_locations].indesc = loc->indesc ?
+                                                   : &internal_indesc;
        erec->num_locations++;
 }