mosquitto_memcmp_const is now more constant time.

This commit is contained in:
Roger A. Light 2023-06-08 23:21:32 +01:00
parent 02d36f9946
commit 67ac8cbe17
4 changed files with 4 additions and 9 deletions

View File

@ -19,6 +19,7 @@ Broker:
- Broker will log warnings if sensitive files are world readable/writable, or - Broker will log warnings if sensitive files are world readable/writable, or
if the owner/group is not the same as the user/group the broker is running if the owner/group is not the same as the user/group the broker is running
as. In future versions the broker will refuse to open these files. as. In future versions the broker will refuse to open these files.
- mosquitto_memcmp_const is now more constant time.
Client library: Client library:
- Use CLOCK_BOOTTIME when available, to keep track of time. This solves the - Use CLOCK_BOOTTIME when available, to keep track of time. This solves the

View File

@ -163,9 +163,7 @@ static int memcmp_const(const void *a, const void *b, size_t len)
if(!a || !b) return 1; if(!a || !b) return 1;
for(i=0; i<len; i++){ for(i=0; i<len; i++){
if( ((char *)a)[i] != ((char *)b)[i] ){ rc |= ((char *)a)[i] ^ ((char *)b)[i];
rc = 1;
}
} }
return rc; return rc;
} }

View File

@ -201,9 +201,7 @@ int pw__memcmp_const(const void *a, const void *b, size_t len)
if(!a || !b) return 1; if(!a || !b) return 1;
for(i=0; i<len; i++){ for(i=0; i<len; i++){
if( ((char *)a)[i] != ((char *)b)[i] ){ rc |= ((char *)a)[i] ^ ((char *)b)[i];
rc = 1;
}
} }
return rc; return rc;
} }

View File

@ -980,9 +980,7 @@ static int mosquitto__memcmp_const(const void *a, const void *b, size_t len)
if(!a || !b) return 1; if(!a || !b) return 1;
for(i=0; i<len; i++){ for(i=0; i<len; i++){
if( ((char *)a)[i] != ((char *)b)[i] ){ rc |= ((char *)a)[i] ^ ((char *)b)[i];
rc = 1;
}
} }
return rc; return rc;
} }