mirror of
https://github.com/hashcat/hashcat
synced 2025-03-26 12:12:43 +01:00
Prepare file_to_buffer() for later use
This commit is contained in:
parent
51b1744805
commit
7668ec5865
@ -107,4 +107,6 @@ int input_tokenizer (const u8 *input_buf, const int input_len, hc_token_t *token
|
|||||||
bool is_apple_silicon (void);
|
bool is_apple_silicon (void);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
char *file_to_buffer (const char *filename);
|
||||||
|
|
||||||
#endif // _SHARED_H
|
#endif // _SHARED_H
|
||||||
|
31
src/shared.c
31
src/shared.c
@ -1397,3 +1397,34 @@ bool is_apple_silicon (void)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#endif // __APPLE__
|
#endif // __APPLE__
|
||||||
|
|
||||||
|
char *file_to_buffer (const char *filename)
|
||||||
|
{
|
||||||
|
HCFILE fp;
|
||||||
|
|
||||||
|
if (hc_fopen (&fp, filename, "r") == true)
|
||||||
|
{
|
||||||
|
struct stat st;
|
||||||
|
|
||||||
|
memset (&st, 0, sizeof (st));
|
||||||
|
|
||||||
|
if (hc_fstat (&fp, &st))
|
||||||
|
{
|
||||||
|
hc_fclose (&fp);
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
char *buffer = malloc (st.st_size + 1);
|
||||||
|
|
||||||
|
const size_t nread = hc_fread (buffer, 1, st.st_size, &fp);
|
||||||
|
|
||||||
|
hc_fclose (&fp);
|
||||||
|
|
||||||
|
buffer[nread] = 0;
|
||||||
|
|
||||||
|
return buffer;
|
||||||
|
}
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user