Small cleanup

This commit is contained in:
twinaphex 2019-04-27 04:43:07 +02:00
parent 3e72c502a8
commit 58073eeb15
2 changed files with 6 additions and 5 deletions

View File

@ -760,6 +760,7 @@ bool netplay_handshake_pre_password(netplay_t *netplay,
ssize_t recvd; ssize_t recvd;
char msg[512]; char msg[512];
bool correct = false; bool correct = false;
size_t password_size;
settings_t *settings = config_get_ptr(); settings_t *settings = config_get_ptr();
msg[0] = '\0'; msg[0] = '\0';
@ -786,13 +787,14 @@ bool netplay_handshake_pre_password(netplay_t *netplay,
/* Calculate the correct password hash(es) and compare */ /* Calculate the correct password hash(es) and compare */
correct = false; correct = false;
snprintf(password, sizeof(password), "%08X", connection->salt); snprintf(password, sizeof(password), "%08X", connection->salt);
password_size = strlen(password);
if (settings->paths.netplay_password[0]) if (settings->paths.netplay_password[0])
{ {
strlcpy(password + 8, strlcpy(password + 8,
settings->paths.netplay_password, sizeof(password)-8); settings->paths.netplay_password, sizeof(password)-8);
sha256_hash(hash, (uint8_t *) password, strlen(password)); sha256_hash(hash, (uint8_t *) password, password_size);
if (!memcmp(password_buf.password, hash, NETPLAY_PASS_HASH_LEN)) if (!memcmp(password_buf.password, hash, NETPLAY_PASS_HASH_LEN))
{ {
@ -805,7 +807,7 @@ bool netplay_handshake_pre_password(netplay_t *netplay,
strlcpy(password + 8, strlcpy(password + 8,
settings->paths.netplay_spectate_password, sizeof(password)-8); settings->paths.netplay_spectate_password, sizeof(password)-8);
sha256_hash(hash, (uint8_t *) password, strlen(password)); sha256_hash(hash, (uint8_t *) password, password_size);
if (!memcmp(password_buf.password, hash, NETPLAY_PASS_HASH_LEN)) if (!memcmp(password_buf.password, hash, NETPLAY_PASS_HASH_LEN))
correct = true; correct = true;

View File

@ -135,9 +135,8 @@ static int task_image_iterate_process_transfer(struct nbio_image_handle *image)
for (i = 0; i < image->processing_pos_increment; i++) for (i = 0; i < image->processing_pos_increment; i++)
{ {
retval = task_image_process(image, if ((retval = task_image_process(image,
&width, &height); &width, &height) != IMAGE_PROCESS_NEXT))
if (retval != IMAGE_PROCESS_NEXT)
break; break;
} }