]> git.ipfire.org Git - thirdparty/ipxe.git/commitdiff
[slam] Avoid NULL pointer dereference in slam_pull_value()
authorMichael Brown <mcb30@ipxe.org>
Tue, 21 Mar 2017 12:57:36 +0000 (14:57 +0200)
committerMichael Brown <mcb30@ipxe.org>
Tue, 21 Mar 2017 12:57:36 +0000 (14:57 +0200)
Signed-off-by: Michael Brown <mcb30@ipxe.org>
src/net/udp/slam.c

index 61dd7d985dab17402d7248ea5920a4c621ae5774..c165b4fb9671ddb2e52f8dff1fb6924a8e69dd0f 100644 (file)
@@ -400,12 +400,16 @@ static int slam_pull_value ( struct slam_request *slam,
                return -EINVAL;
        }
 
-       /* Read value */
+       /* Strip value */
        iob_pull ( iobuf, len );
-       *value = ( *data & 0x1f );
-       while ( --len ) {
-               *value <<= 8;
-               *value |= *(++data);
+
+       /* Read value, if applicable */
+       if ( value ) {
+               *value = ( *data & 0x1f );
+               while ( --len ) {
+                       *value <<= 8;
+                       *value |= *(++data);
+               }
        }
 
        return 0;