1
mirror of https://github.com/hashcat/hashcat synced 2024-12-01 20:18:12 +01:00

always check the input for NULL before the strtok_r () calls

This commit is contained in:
philsmd 2017-02-14 20:46:03 +01:00
parent f9bbd42b4a
commit f535eb2bd0
No known key found for this signature in database
GPG Key ID: 4F25D016D9D6A8AF
5 changed files with 18 additions and 6 deletions

View File

@ -63,6 +63,8 @@ int set_cpu_affinity (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx)
char *devices = hcstrdup (user_options->cpu_affinity);
if (devices == NULL) return -1;
char *saveptr;
char *next = strtok_r (devices, ",", &saveptr);
@ -88,7 +90,7 @@ int set_cpu_affinity (MAYBE_UNUSED hashcat_ctx_t *hashcat_ctx)
hcfree (devices);
return (-1);
return -1;
}
#if defined (_WIN)

View File

@ -99,7 +99,7 @@ int cpu_crc32 (hashcat_ctx_t *hashcat_ctx, const char *filename, u8 keytab[64])
{
event_log_error (hashcat_ctx, "%s: %s", filename, strerror (errno));
return (-1);
return -1;
}
#define MAX_KEY_SIZE (1024 * 1024)

View File

@ -5112,10 +5112,10 @@ int ikepsk_md5_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYBE
size_t in_len[9] = { 0 };
char *saveptr;
if (input_buf == NULL) return (PARSER_HASH_VALUE);
char *saveptr;
in_off[0] = (u8 *) strtok_r ((char *) input_buf, ":", &saveptr);
if (in_off[0] == NULL) return (PARSER_SEPARATOR_UNMATCHED);
@ -5200,10 +5200,10 @@ int ikepsk_sha1_parse_hash (u8 *input_buf, u32 input_len, hash_t *hash_buf, MAYB
size_t in_len[9] = { 0 };
char *saveptr;
if (input_buf == NULL) return (PARSER_HASH_VALUE);
char *saveptr;
in_off[0] = (u8 *) strtok_r ((char *) input_buf, ":", &saveptr);
if (in_off[0] == NULL) return (PARSER_SEPARATOR_UNMATCHED);
@ -22511,6 +22511,8 @@ int hashconfig_general_defaults (hashcat_ctx_t *hashcat_ctx)
char *keyfiles = hcstrdup (tcvc_keyfiles);
if (keyfiles == NULL) return -1;
char *saveptr;
char *keyfile = strtok_r (keyfiles, ",", &saveptr);

View File

@ -180,6 +180,8 @@ static int setup_opencl_platforms_filter (hashcat_ctx_t *hashcat_ctx, const char
{
char *platforms = hcstrdup (opencl_platforms);
if (platforms == NULL) return -1;
char *saveptr;
char *next = strtok_r (platforms, ",", &saveptr);
@ -221,6 +223,8 @@ static int setup_devices_filter (hashcat_ctx_t *hashcat_ctx, const char *opencl_
{
char *devices = hcstrdup (opencl_devices);
if (devices == NULL) return -1;
char *saveptr;
char *next = strtok_r (devices, ",", &saveptr);
@ -262,6 +266,8 @@ static int setup_device_types_filter (hashcat_ctx_t *hashcat_ctx, const char *op
{
char *device_types = hcstrdup (opencl_device_types);
if (device_types == NULL) return -1;
char *saveptr;
char *next = strtok_r (device_types, ",", &saveptr);

View File

@ -119,6 +119,8 @@ int tuning_db_init (hashcat_ctx_t *hashcat_ctx)
int token_cnt = 0;
if (line_buf == NULL) continue;
char *saveptr;
char *next = strtok_r (line_buf, "\t ", &saveptr);