mirror of
https://github.com/hashcat/hashcat
synced 2024-11-06 11:40:38 +01:00
Fixed string not null terminated when reading maskfiles
This commit is contained in:
parent
8ebd5188eb
commit
dc4f96f42e
@ -48,6 +48,7 @@
|
||||
- Fixed nvapi datatype definition for NvS32 and NvU32
|
||||
- Fixed WPA/WPA2 cracking in case eapol frame is >= 248 byte
|
||||
- Fixed string not null terminated inside workaround for checking drm driver path
|
||||
- Fixed string not null terminated when reading maskfiles
|
||||
|
||||
##
|
||||
## Technical
|
||||
|
@ -14,6 +14,8 @@ u64 count_lines (FILE *fd);
|
||||
|
||||
int fgetl (FILE *fp, char *line_buf);
|
||||
|
||||
size_t superchop_with_length (char *buf, const size_t len);
|
||||
|
||||
int in_superchop (char *buf);
|
||||
|
||||
#endif // _FILEHANDLING_H
|
||||
|
@ -82,6 +82,37 @@ int fgetl (FILE *fp, char *line_buf)
|
||||
return (line_len);
|
||||
}
|
||||
|
||||
|
||||
size_t superchop_with_length (char *buf, const size_t len)
|
||||
{
|
||||
size_t new_len = len;
|
||||
|
||||
while (new_len)
|
||||
{
|
||||
if (buf[new_len - 1] == '\n')
|
||||
{
|
||||
new_len--;
|
||||
|
||||
buf[new_len] = 0;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
if (buf[new_len - 1] == '\r')
|
||||
{
|
||||
new_len--;
|
||||
|
||||
buf[new_len] = 0;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
return new_len;
|
||||
}
|
||||
|
||||
int in_superchop (char *buf)
|
||||
{
|
||||
size_t len = strlen (buf);
|
||||
@ -92,6 +123,8 @@ int in_superchop (char *buf)
|
||||
{
|
||||
len--;
|
||||
|
||||
buf[len] = 0;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -99,13 +132,13 @@ int in_superchop (char *buf)
|
||||
{
|
||||
len--;
|
||||
|
||||
buf[len] = 0;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
buf[len] = 0;
|
||||
|
||||
return len;
|
||||
}
|
||||
|
@ -567,7 +567,9 @@ static int mp_setup_usr (hashcat_ctx_t *hashcat_ctx, cs_t *mp_sys, cs_t *mp_usr,
|
||||
return -1;
|
||||
}
|
||||
|
||||
const size_t len = in_superchop (mp_file);
|
||||
mp_file[nread] = 0;
|
||||
|
||||
const size_t len = superchop_with_length (mp_file, nread);
|
||||
|
||||
if (len == 0)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user