Explorar el Código

[settings] Fix erroneous bit-masking in fetch_uintz_setting()

tags/v0.9.8
Michael Brown hace 15 años
padre
commit
c5a88ed553
Se han modificado 1 ficheros con 2 adiciones y 1 borrados
  1. 2
    1
      src/core/settings.c

+ 2
- 1
src/core/settings.c Ver fichero

@@ -544,7 +544,8 @@ int fetch_uint_setting ( struct settings *settings, struct setting *setting,
544 544
 		return len;
545 545
 
546 546
 	/* Mask off sign-extended bits */
547
-	*value = ( svalue & ( -1UL >> ( sizeof ( long ) - len ) ) );
547
+	assert ( len <= ( int ) sizeof ( long ) );
548
+	*value = ( svalue & ( -1UL >> ( 8 * ( sizeof ( long ) - len ) ) ) );
548 549
 
549 550
 	return len;
550 551
 }

Loading…
Cancelar
Guardar