mirror of
https://github.com/hashcat/hashcat.git
synced 2024-11-14 03:39:09 +00:00
Merge pull request #2079 from matrix/strtok_r_1
switch from strtok to strtok_r
This commit is contained in:
commit
40cb68ee47
@ -188,7 +188,9 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE
|
||||
input[line_len] = '\0';
|
||||
memcpy (&input, line_buf, line_len);
|
||||
|
||||
char *p = strtok (input, "*");
|
||||
char *saveptr = NULL;
|
||||
|
||||
char *p = strtok_r (input, "*", &saveptr);
|
||||
if (p == NULL) return PARSER_HASH_LENGTH;
|
||||
if (strncmp (p, SIGNATURE_PKZIP_V1, 7) != 0 && strncmp (p, SIGNATURE_PKZIP_V2, 8) != 0) return PARSER_SIGNATURE_UNMATCHED;
|
||||
|
||||
@ -205,27 +207,27 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE
|
||||
// check here that the hash_count is valid for the attack type
|
||||
if (pkzip->hash_count != 1) return PARSER_HASH_VALUE;
|
||||
|
||||
p = strtok (NULL, "*");
|
||||
p = strtok_r (NULL, "*", &saveptr);
|
||||
if (p == NULL) return PARSER_HASH_LENGTH;
|
||||
pkzip->checksum_size = atoi (p);
|
||||
if (pkzip->checksum_size != 1 && pkzip->checksum_size != 2) return PARSER_HASH_LENGTH;
|
||||
|
||||
p = strtok (NULL, "*");
|
||||
p = strtok_r (NULL, "*", &saveptr);
|
||||
if (p == NULL) return PARSER_HASH_LENGTH;
|
||||
pkzip->hash.data_type_enum = atoi (p);
|
||||
if (pkzip->hash.data_type_enum > 3) return PARSER_HASH_LENGTH;
|
||||
|
||||
p = strtok (NULL, "*");
|
||||
p = strtok_r (NULL, "*", &saveptr);
|
||||
if (p == NULL) return PARSER_HASH_LENGTH;
|
||||
pkzip->hash.magic_type_enum = atoi (p);
|
||||
|
||||
if (pkzip->hash.data_type_enum > 1)
|
||||
{
|
||||
p = strtok (NULL, "*");
|
||||
p = strtok_r (NULL, "*", &saveptr);
|
||||
if (p == NULL) return PARSER_HASH_LENGTH;
|
||||
pkzip->hash.compressed_length = strtoul (p, NULL, 16);
|
||||
|
||||
p = strtok (NULL, "*");
|
||||
p = strtok_r (NULL, "*", &saveptr);
|
||||
if (p == NULL) return PARSER_HASH_LENGTH;
|
||||
pkzip->hash.uncompressed_length = strtoul (p, NULL, 16);
|
||||
if (pkzip->hash.compressed_length > MAX_DATA)
|
||||
@ -233,31 +235,31 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE
|
||||
return PARSER_TOKEN_LENGTH;
|
||||
}
|
||||
|
||||
p = strtok (NULL, "*");
|
||||
p = strtok_r (NULL, "*", &saveptr);
|
||||
if (p == NULL) return PARSER_HASH_LENGTH;
|
||||
u32 crc32 = 0;
|
||||
sscanf (p, "%x", &crc32);
|
||||
pkzip->hash.crc32 = crc32;
|
||||
|
||||
p = strtok (NULL, "*");
|
||||
p = strtok_r (NULL, "*", &saveptr);
|
||||
if (p == NULL) return PARSER_HASH_LENGTH;
|
||||
pkzip->hash.offset = strtoul (p, NULL, 16);
|
||||
|
||||
p = strtok (NULL, "*");
|
||||
p = strtok_r (NULL, "*", &saveptr);
|
||||
if (p == NULL) return PARSER_HASH_LENGTH;
|
||||
pkzip->hash.additional_offset = strtoul (p, NULL, 16);
|
||||
}
|
||||
|
||||
p = strtok (NULL, "*");
|
||||
p = strtok_r (NULL, "*", &saveptr);
|
||||
if (p == NULL) return PARSER_HASH_LENGTH;
|
||||
pkzip->hash.compression_type = atoi (p);
|
||||
if (pkzip->hash.compression_type != 8) return PARSER_PKZIP_CT_UNMATCHED;
|
||||
|
||||
p = strtok (NULL, "*");
|
||||
p = strtok_r (NULL, "*", &saveptr);
|
||||
if (p == NULL) return PARSER_HASH_LENGTH;
|
||||
pkzip->hash.data_length = strtoul (p, NULL, 16);
|
||||
|
||||
p = strtok (NULL, "*");
|
||||
p = strtok_r (NULL, "*", &saveptr);
|
||||
if (p == NULL) return PARSER_HASH_LENGTH;
|
||||
u16 checksum_from_crc = 0;
|
||||
sscanf (p, "%hx", &checksum_from_crc);
|
||||
@ -265,7 +267,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE
|
||||
|
||||
if (pkzip->version == 2)
|
||||
{
|
||||
p = strtok (NULL, "*");
|
||||
p = strtok_r (NULL, "*", &saveptr);
|
||||
if (p == NULL) return PARSER_HASH_LENGTH;
|
||||
u16 checksum_from_timestamp = 0;
|
||||
sscanf (p, "%hx", &checksum_from_timestamp);
|
||||
@ -276,7 +278,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE
|
||||
pkzip->hash.checksum_from_timestamp = pkzip->hash.checksum_from_crc;
|
||||
}
|
||||
|
||||
p = strtok (NULL, "*");
|
||||
p = strtok_r (NULL, "*", &saveptr);
|
||||
if (p == NULL) return PARSER_HASH_LENGTH;
|
||||
|
||||
hex_to_binary (p, strlen (p), (char *) &(pkzip->hash.data));
|
||||
|
@ -188,7 +188,9 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE
|
||||
input[line_len] = '\0';
|
||||
memcpy (&input, line_buf, line_len);
|
||||
|
||||
char *p = strtok (input, "*");
|
||||
char *saveptr = NULL;
|
||||
|
||||
char *p = strtok_r (input, "*", &saveptr);
|
||||
if (p == NULL) return PARSER_HASH_LENGTH;
|
||||
if (strncmp (p, SIGNATURE_PKZIP_V1, 7) != 0 && strncmp (p, SIGNATURE_PKZIP_V2, 8) != 0) return PARSER_SIGNATURE_UNMATCHED;
|
||||
|
||||
@ -204,27 +206,27 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE
|
||||
// check here that the hash_count is valid for the attack type
|
||||
if (pkzip->hash_count != 1) return PARSER_HASH_VALUE;
|
||||
|
||||
p = strtok (NULL, "*");
|
||||
p = strtok_r (NULL, "*", &saveptr);
|
||||
if (p == NULL) return PARSER_HASH_LENGTH;
|
||||
pkzip->checksum_size = atoi (p);
|
||||
if (pkzip->checksum_size != 1 && pkzip->checksum_size != 2) return PARSER_HASH_LENGTH;
|
||||
|
||||
p = strtok (NULL, "*");
|
||||
p = strtok_r (NULL, "*", &saveptr);
|
||||
if (p == NULL) return PARSER_HASH_LENGTH;
|
||||
pkzip->hash.data_type_enum = atoi (p);
|
||||
if (pkzip->hash.data_type_enum > 3) return PARSER_HASH_LENGTH;
|
||||
|
||||
p = strtok (NULL, "*");
|
||||
p = strtok_r (NULL, "*", &saveptr);
|
||||
if (p == NULL) return PARSER_HASH_LENGTH;
|
||||
pkzip->hash.magic_type_enum = atoi (p);
|
||||
|
||||
if (pkzip->hash.data_type_enum > 1)
|
||||
{
|
||||
p = strtok (NULL, "*");
|
||||
p = strtok_r (NULL, "*", &saveptr);
|
||||
if (p == NULL) return PARSER_HASH_LENGTH;
|
||||
pkzip->hash.compressed_length = strtoul (p, NULL, 16);
|
||||
|
||||
p = strtok (NULL, "*");
|
||||
p = strtok_r (NULL, "*", &saveptr);
|
||||
if (p == NULL) return PARSER_HASH_LENGTH;
|
||||
pkzip->hash.uncompressed_length = strtoul (p, NULL, 16);
|
||||
if (pkzip->hash.compressed_length > MAX_DATA)
|
||||
@ -232,31 +234,31 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE
|
||||
return PARSER_TOKEN_LENGTH;
|
||||
}
|
||||
|
||||
p = strtok (NULL, "*");
|
||||
p = strtok_r (NULL, "*", &saveptr);
|
||||
if (p == NULL) return PARSER_HASH_LENGTH;
|
||||
u32 crc32 = 0;
|
||||
sscanf (p, "%x", &crc32);
|
||||
pkzip->hash.crc32 = crc32;
|
||||
|
||||
p = strtok (NULL, "*");
|
||||
p = strtok_r (NULL, "*", &saveptr);
|
||||
if (p == NULL) return PARSER_HASH_LENGTH;
|
||||
pkzip->hash.offset = strtoul (p, NULL, 16);
|
||||
|
||||
p = strtok (NULL, "*");
|
||||
p = strtok_r (NULL, "*", &saveptr);
|
||||
if (p == NULL) return PARSER_HASH_LENGTH;
|
||||
pkzip->hash.additional_offset = strtoul (p, NULL, 16);
|
||||
}
|
||||
|
||||
p = strtok (NULL, "*");
|
||||
p = strtok_r (NULL, "*", &saveptr);
|
||||
if (p == NULL) return PARSER_HASH_LENGTH;
|
||||
pkzip->hash.compression_type = atoi (p);
|
||||
if (pkzip->hash.compression_type != 0) return PARSER_PKZIP_CT_UNMATCHED;
|
||||
|
||||
p = strtok (NULL, "*");
|
||||
p = strtok_r (NULL, "*", &saveptr);
|
||||
if (p == NULL) return PARSER_HASH_LENGTH;
|
||||
pkzip->hash.data_length = strtoul (p, NULL, 16);
|
||||
|
||||
p = strtok (NULL, "*");
|
||||
p = strtok_r (NULL, "*", &saveptr);
|
||||
if (p == NULL) return PARSER_HASH_LENGTH;
|
||||
u16 checksum_from_crc = 0;
|
||||
sscanf (p, "%hx", &checksum_from_crc);
|
||||
@ -264,7 +266,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE
|
||||
|
||||
if (pkzip->version == 2)
|
||||
{
|
||||
p = strtok (NULL, "*");
|
||||
p = strtok_r (NULL, "*", &saveptr);
|
||||
if (p == NULL) return PARSER_HASH_LENGTH;
|
||||
u16 checksum_from_timestamp = 0;
|
||||
sscanf (p, "%hx", &checksum_from_timestamp);
|
||||
@ -275,7 +277,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE
|
||||
pkzip->hash.checksum_from_timestamp = pkzip->hash.checksum_from_crc;
|
||||
}
|
||||
|
||||
p = strtok (NULL, "*");
|
||||
p = strtok_r (NULL, "*", &saveptr);
|
||||
if (p == NULL) return PARSER_HASH_LENGTH;
|
||||
|
||||
hex_to_binary (p, strlen (p), (char *) &(pkzip->hash.data));
|
||||
|
@ -188,7 +188,9 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE
|
||||
input[line_len] = '\0';
|
||||
memcpy (&input, line_buf, line_len);
|
||||
|
||||
char *p = strtok (input, "*");
|
||||
char *saveptr = NULL;
|
||||
|
||||
char *p = strtok_r (input, "*", &saveptr);
|
||||
if (p == NULL) return PARSER_HASH_LENGTH;
|
||||
if (strncmp (p, SIGNATURE_PKZIP_V1, 7) != 0 && strncmp (p, SIGNATURE_PKZIP_V2, 8) != 0) return PARSER_SIGNATURE_UNMATCHED;
|
||||
|
||||
@ -204,29 +206,29 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE
|
||||
// check here that the hash_count is valid for the attack type
|
||||
if (pkzip->hash_count > 8) return PARSER_HASH_VALUE;
|
||||
|
||||
p = strtok (NULL, "*");
|
||||
p = strtok_r (NULL, "*", &saveptr);
|
||||
if (p == NULL) return PARSER_HASH_LENGTH;
|
||||
pkzip->checksum_size = atoi (p);
|
||||
if (pkzip->checksum_size != 1 && pkzip->checksum_size != 2) return PARSER_HASH_LENGTH;
|
||||
|
||||
for (int i = 0; i < pkzip->hash_count; i++)
|
||||
{
|
||||
p = strtok (NULL, "*");
|
||||
p = strtok_r (NULL, "*", &saveptr);
|
||||
if (p == NULL) return PARSER_HASH_LENGTH;
|
||||
pkzip->hashes[i].data_type_enum = atoi (p);
|
||||
if (pkzip->hashes[i].data_type_enum > 3) return PARSER_HASH_LENGTH;
|
||||
|
||||
p = strtok (NULL, "*");
|
||||
p = strtok_r (NULL, "*", &saveptr);
|
||||
if (p == NULL) return PARSER_HASH_LENGTH;
|
||||
pkzip->hashes[i].magic_type_enum = atoi (p);
|
||||
|
||||
if (pkzip->hashes[i].data_type_enum > 1)
|
||||
{
|
||||
p = strtok (NULL, "*");
|
||||
p = strtok_r (NULL, "*", &saveptr);
|
||||
if (p == NULL) return PARSER_HASH_LENGTH;
|
||||
pkzip->hashes[i].compressed_length = strtoul (p, NULL, 16);
|
||||
|
||||
p = strtok (NULL, "*");
|
||||
p = strtok_r (NULL, "*", &saveptr);
|
||||
if (p == NULL) return PARSER_HASH_LENGTH;
|
||||
pkzip->hashes[i].uncompressed_length = strtoul (p, NULL, 16);
|
||||
if (pkzip->hashes[i].compressed_length > MAX_DATA)
|
||||
@ -234,31 +236,31 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE
|
||||
return PARSER_TOKEN_LENGTH;
|
||||
}
|
||||
|
||||
p = strtok (NULL, "*");
|
||||
p = strtok_r (NULL, "*", &saveptr);
|
||||
if (p == NULL) return PARSER_HASH_LENGTH;
|
||||
u32 crc32 = 0;
|
||||
sscanf (p, "%x", &crc32);
|
||||
pkzip->hashes[i].crc32 = crc32;
|
||||
|
||||
p = strtok (NULL, "*");
|
||||
p = strtok_r (NULL, "*", &saveptr);
|
||||
if (p == NULL) return PARSER_HASH_LENGTH;
|
||||
pkzip->hashes[i].offset = strtoul (p, NULL, 16);
|
||||
|
||||
p = strtok (NULL, "*");
|
||||
p = strtok_r (NULL, "*", &saveptr);
|
||||
if (p == NULL) return PARSER_HASH_LENGTH;
|
||||
pkzip->hashes[i].additional_offset = strtoul (p, NULL, 16);
|
||||
}
|
||||
|
||||
p = strtok (NULL, "*");
|
||||
p = strtok_r (NULL, "*", &saveptr);
|
||||
if (p == NULL) return PARSER_HASH_LENGTH;
|
||||
pkzip->hashes[i].compression_type = atoi (p);
|
||||
if (pkzip->hashes[i].compression_type != 8) return PARSER_PKZIP_CT_UNMATCHED;
|
||||
|
||||
p = strtok (NULL, "*");
|
||||
p = strtok_r (NULL, "*", &saveptr);
|
||||
if (p == NULL) return PARSER_HASH_LENGTH;
|
||||
pkzip->hashes[i].data_length = strtoul (p, NULL, 16);
|
||||
|
||||
p = strtok (NULL, "*");
|
||||
p = strtok_r (NULL, "*", &saveptr);
|
||||
if (p == NULL) return PARSER_HASH_LENGTH;
|
||||
u16 checksum_from_crc = 0;
|
||||
sscanf (p, "%hx", &checksum_from_crc);
|
||||
@ -266,7 +268,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE
|
||||
|
||||
if (pkzip->version == 2)
|
||||
{
|
||||
p = strtok (NULL, "*");
|
||||
p = strtok_r (NULL, "*", &saveptr);
|
||||
if (p == NULL) return PARSER_HASH_LENGTH;
|
||||
u16 checksum_from_timestamp = 0;
|
||||
sscanf (p, "%hx", &checksum_from_timestamp);
|
||||
@ -277,7 +279,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE
|
||||
pkzip->hashes[i].checksum_from_timestamp = pkzip->hashes[i].checksum_from_crc;
|
||||
}
|
||||
|
||||
p = strtok (NULL, "*");
|
||||
p = strtok_r (NULL, "*", &saveptr);
|
||||
if (p == NULL) return PARSER_HASH_LENGTH;
|
||||
|
||||
hex_to_binary (p, strlen (p), (char *) &(pkzip->hashes[i].data));
|
||||
|
@ -188,7 +188,9 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE
|
||||
input[line_len] = '\0';
|
||||
memcpy (&input, line_buf, line_len);
|
||||
|
||||
char *p = strtok (input, "*");
|
||||
char *saveptr = NULL;
|
||||
|
||||
char *p = strtok_r (input, "*", &saveptr);
|
||||
if (p == NULL) return PARSER_HASH_LENGTH;
|
||||
if (strncmp (p, SIGNATURE_PKZIP_V1, 7) != 0 && strncmp (p, SIGNATURE_PKZIP_V2, 8) != 0) return PARSER_SIGNATURE_UNMATCHED;
|
||||
|
||||
@ -204,29 +206,29 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE
|
||||
// check here that the hash_count is valid for the attack type
|
||||
if (pkzip->hash_count > 8) return PARSER_HASH_VALUE;
|
||||
|
||||
p = strtok (NULL, "*");
|
||||
p = strtok_r (NULL, "*", &saveptr);
|
||||
if (p == NULL) return PARSER_HASH_LENGTH;
|
||||
pkzip->checksum_size = atoi (p);
|
||||
if (pkzip->checksum_size != 1 && pkzip->checksum_size != 2) return PARSER_HASH_LENGTH;
|
||||
|
||||
for (int i = 0; i < pkzip->hash_count; i++)
|
||||
{
|
||||
p = strtok (NULL, "*");
|
||||
p = strtok_r (NULL, "*", &saveptr);
|
||||
if (p == NULL) return PARSER_HASH_LENGTH;
|
||||
pkzip->hashes[i].data_type_enum = atoi (p);
|
||||
if (pkzip->hashes[i].data_type_enum > 3) return PARSER_HASH_LENGTH;
|
||||
|
||||
p = strtok (NULL, "*");
|
||||
p = strtok_r (NULL, "*", &saveptr);
|
||||
if (p == NULL) return PARSER_HASH_LENGTH;
|
||||
pkzip->hashes[i].magic_type_enum = atoi (p);
|
||||
|
||||
if (pkzip->hashes[i].data_type_enum > 1)
|
||||
{
|
||||
p = strtok (NULL, "*");
|
||||
p = strtok_r (NULL, "*", &saveptr);
|
||||
if (p == NULL) return PARSER_HASH_LENGTH;
|
||||
pkzip->hashes[i].compressed_length = strtoul (p, NULL, 16);
|
||||
|
||||
p = strtok (NULL, "*");
|
||||
p = strtok_r (NULL, "*", &saveptr);
|
||||
if (p == NULL) return PARSER_HASH_LENGTH;
|
||||
pkzip->hashes[i].uncompressed_length = strtoul (p, NULL, 16);
|
||||
if (pkzip->hashes[i].compressed_length > MAX_DATA)
|
||||
@ -234,31 +236,31 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE
|
||||
return PARSER_TOKEN_LENGTH;
|
||||
}
|
||||
|
||||
p = strtok (NULL, "*");
|
||||
p = strtok_r (NULL, "*", &saveptr);
|
||||
if (p == NULL) return PARSER_HASH_LENGTH;
|
||||
u32 crc32 = 0;
|
||||
sscanf (p, "%x", &crc32);
|
||||
pkzip->hashes[i].crc32 = crc32;
|
||||
|
||||
p = strtok (NULL, "*");
|
||||
p = strtok_r (NULL, "*", &saveptr);
|
||||
if (p == NULL) return PARSER_HASH_LENGTH;
|
||||
pkzip->hashes[i].offset = strtoul (p, NULL, 16);
|
||||
|
||||
p = strtok (NULL, "*");
|
||||
p = strtok_r (NULL, "*", &saveptr);
|
||||
if (p == NULL) return PARSER_HASH_LENGTH;
|
||||
pkzip->hashes[i].additional_offset = strtoul (p, NULL, 16);
|
||||
}
|
||||
|
||||
p = strtok (NULL, "*");
|
||||
p = strtok_r (NULL, "*", &saveptr);
|
||||
if (p == NULL) return PARSER_HASH_LENGTH;
|
||||
pkzip->hashes[i].compression_type = atoi (p);
|
||||
if (pkzip->hashes[i].compression_type != 8 && pkzip->hashes[i].compression_type != 0) return PARSER_HASH_VALUE;
|
||||
|
||||
p = strtok (NULL, "*");
|
||||
p = strtok_r (NULL, "*", &saveptr);
|
||||
if (p == NULL) return PARSER_HASH_LENGTH;
|
||||
pkzip->hashes[i].data_length = strtoul (p, NULL, 16);
|
||||
|
||||
p = strtok (NULL, "*");
|
||||
p = strtok_r (NULL, "*", &saveptr);
|
||||
if (p == NULL) return PARSER_HASH_LENGTH;
|
||||
u16 checksum_from_crc = 0;
|
||||
sscanf (p, "%hx", &checksum_from_crc);
|
||||
@ -266,7 +268,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE
|
||||
|
||||
if (pkzip->version == 2)
|
||||
{
|
||||
p = strtok (NULL, "*");
|
||||
p = strtok_r (NULL, "*", &saveptr);
|
||||
if (p == NULL) return PARSER_HASH_LENGTH;
|
||||
u16 checksum_from_timestamp = 0;
|
||||
sscanf (p, "%hx", &checksum_from_timestamp);
|
||||
@ -277,7 +279,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE
|
||||
pkzip->hashes[i].checksum_from_timestamp = pkzip->hashes[i].checksum_from_crc;
|
||||
}
|
||||
|
||||
p = strtok (NULL, "*");
|
||||
p = strtok_r (NULL, "*", &saveptr);
|
||||
if (p == NULL) return PARSER_HASH_LENGTH;
|
||||
|
||||
hex_to_binary (p, strlen (p), (char *) &(pkzip->hashes[i].data));
|
||||
|
@ -188,7 +188,9 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE
|
||||
input[line_len] = '\0';
|
||||
memcpy (&input, line_buf, line_len);
|
||||
|
||||
char *p = strtok (input, "*");
|
||||
char *saveptr = NULL;
|
||||
|
||||
char *p = strtok_r (input, "*", &saveptr);
|
||||
if (p == NULL) return PARSER_HASH_LENGTH;
|
||||
if (strncmp (p, SIGNATURE_PKZIP_V1, 7) != 0 && strncmp (p, SIGNATURE_PKZIP_V2, 8) != 0) return PARSER_SIGNATURE_UNMATCHED;
|
||||
|
||||
@ -205,29 +207,29 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE
|
||||
if (pkzip->hash_count > 8) return PARSER_HASH_VALUE;
|
||||
if (pkzip->hash_count < 3) return PARSER_HASH_VALUE;
|
||||
|
||||
p = strtok (NULL, "*");
|
||||
p = strtok_r (NULL, "*", &saveptr);
|
||||
if (p == NULL) return PARSER_HASH_LENGTH;
|
||||
pkzip->checksum_size = atoi (p);
|
||||
if (pkzip->checksum_size != 1 && pkzip->checksum_size != 2) return PARSER_HASH_LENGTH;
|
||||
|
||||
for (int i = 0; i < pkzip->hash_count; i++)
|
||||
{
|
||||
p = strtok (NULL, "*");
|
||||
p = strtok_r (NULL, "*", &saveptr);
|
||||
if (p == NULL) return PARSER_HASH_LENGTH;
|
||||
pkzip->hashes[i].data_type_enum = atoi (p);
|
||||
if (pkzip->hashes[i].data_type_enum > 3) return PARSER_HASH_LENGTH;
|
||||
|
||||
p = strtok (NULL, "*");
|
||||
p = strtok_r (NULL, "*", &saveptr);
|
||||
if (p == NULL) return PARSER_HASH_LENGTH;
|
||||
pkzip->hashes[i].magic_type_enum = atoi (p);
|
||||
|
||||
if (pkzip->hashes[i].data_type_enum > 1)
|
||||
{
|
||||
p = strtok (NULL, "*");
|
||||
p = strtok_r (NULL, "*", &saveptr);
|
||||
if (p == NULL) return PARSER_HASH_LENGTH;
|
||||
pkzip->hashes[i].compressed_length = strtoul (p, NULL, 16);
|
||||
|
||||
p = strtok (NULL, "*");
|
||||
p = strtok_r (NULL, "*", &saveptr);
|
||||
if (p == NULL) return PARSER_HASH_LENGTH;
|
||||
pkzip->hashes[i].uncompressed_length = strtoul (p, NULL, 16);
|
||||
if (pkzip->hashes[i].compressed_length > MAX_DATA)
|
||||
@ -235,31 +237,31 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE
|
||||
return PARSER_TOKEN_LENGTH;
|
||||
}
|
||||
|
||||
p = strtok (NULL, "*");
|
||||
p = strtok_r (NULL, "*", &saveptr);
|
||||
if (p == NULL) return PARSER_HASH_LENGTH;
|
||||
u32 crc32 = 0;
|
||||
sscanf (p, "%x", &crc32);
|
||||
pkzip->hashes[i].crc32 = crc32;
|
||||
|
||||
p = strtok (NULL, "*");
|
||||
p = strtok_r (NULL, "*", &saveptr);
|
||||
if (p == NULL) return PARSER_HASH_LENGTH;
|
||||
pkzip->hashes[i].offset = strtoul (p, NULL, 16);
|
||||
|
||||
p = strtok (NULL, "*");
|
||||
p = strtok_r (NULL, "*", &saveptr);
|
||||
if (p == NULL) return PARSER_HASH_LENGTH;
|
||||
pkzip->hashes[i].additional_offset = strtoul (p, NULL, 16);
|
||||
}
|
||||
|
||||
p = strtok (NULL, "*");
|
||||
p = strtok_r (NULL, "*", &saveptr);
|
||||
if (p == NULL) return PARSER_HASH_LENGTH;
|
||||
pkzip->hashes[i].compression_type = atoi (p);
|
||||
if (pkzip->hashes[i].compression_type != 8 && pkzip->hashes[i].compression_type != 0) return PARSER_PKZIP_CT_UNMATCHED;
|
||||
|
||||
p = strtok (NULL, "*");
|
||||
p = strtok_r (NULL, "*", &saveptr);
|
||||
if (p == NULL) return PARSER_HASH_LENGTH;
|
||||
pkzip->hashes[i].data_length = strtoul (p, NULL, 16);
|
||||
|
||||
p = strtok (NULL, "*");
|
||||
p = strtok_r (NULL, "*", &saveptr);
|
||||
if (p == NULL) return PARSER_HASH_LENGTH;
|
||||
u16 checksum_from_crc = 0;
|
||||
sscanf (p, "%hx", &checksum_from_crc);
|
||||
@ -267,7 +269,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE
|
||||
|
||||
if (pkzip->version == 2)
|
||||
{
|
||||
p = strtok (NULL, "*");
|
||||
p = strtok_r (NULL, "*", &saveptr);
|
||||
if (p == NULL) return PARSER_HASH_LENGTH;
|
||||
u16 checksum_from_timestamp = 0;
|
||||
sscanf (p, "%hx", &checksum_from_timestamp);
|
||||
@ -278,7 +280,7 @@ int module_hash_decode (MAYBE_UNUSED const hashconfig_t *hashconfig, MAYBE_UNUSE
|
||||
pkzip->hashes[i].checksum_from_timestamp = pkzip->hashes[i].checksum_from_crc;
|
||||
}
|
||||
|
||||
p = strtok (NULL, "*");
|
||||
p = strtok_r (NULL, "*", &saveptr);
|
||||
if (p == NULL) return PARSER_HASH_LENGTH;
|
||||
|
||||
hex_to_binary (p, strlen (p), (char *) &(pkzip->hashes[i].data));
|
||||
|
Loading…
Reference in New Issue
Block a user