Sfoglia il codice sorgente

[slam] Avoid NULL pointer dereference in slam_pull_value()

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 7 anni fa
parent
commit
64de7dc7fd
1 ha cambiato i file con 9 aggiunte e 5 eliminazioni
  1. 9
    5
      src/net/udp/slam.c

+ 9
- 5
src/net/udp/slam.c Vedi File

@@ -400,12 +400,16 @@ static int slam_pull_value ( struct slam_request *slam,
400 400
 		return -EINVAL;
401 401
 	}
402 402
 
403
-	/* Read value */
403
+	/* Strip value */
404 404
 	iob_pull ( iobuf, len );
405
-	*value = ( *data & 0x1f );
406
-	while ( --len ) {
407
-		*value <<= 8;
408
-		*value |= *(++data);
405
+
406
+	/* Read value, if applicable */
407
+	if ( value ) {
408
+		*value = ( *data & 0x1f );
409
+		while ( --len ) {
410
+			*value <<= 8;
411
+			*value |= *(++data);
412
+		}
409 413
 	}
410 414
 
411 415
 	return 0;

Loading…
Annulla
Salva