mirror of
https://github.com/hashcat/hashcat.git
synced 2025-02-23 13:02:06 +00:00
commit
660e451689
@ -982,54 +982,38 @@ void hc_fclose (HCFILE *fp)
|
|||||||
|
|
||||||
size_t fgetl (HCFILE *fp, char *line_buf, const size_t line_sz)
|
size_t fgetl (HCFILE *fp, char *line_buf, const size_t line_sz)
|
||||||
{
|
{
|
||||||
size_t line_truncated = 0;
|
int c;
|
||||||
|
|
||||||
size_t line_len = 0;
|
size_t line_len = 0;
|
||||||
|
|
||||||
while (!hc_feof (fp))
|
size_t line_truncated = 0;
|
||||||
{
|
|
||||||
const int c = hc_fgetc (fp);
|
|
||||||
|
|
||||||
if (c == EOF) break;
|
while ((c = hc_fgetc (fp)) != EOF)
|
||||||
|
{
|
||||||
|
if (c == '\n') break;
|
||||||
|
|
||||||
if (line_len == line_sz)
|
if (line_len == line_sz)
|
||||||
{
|
{
|
||||||
line_truncated++;
|
line_truncated++;
|
||||||
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
line_buf[line_len] = (char) c;
|
||||||
|
|
||||||
line_buf[line_len] = (char) c;
|
line_len++;
|
||||||
|
}
|
||||||
line_len++;
|
|
||||||
|
|
||||||
if (c == '\n') break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (line_truncated > 0)
|
if (line_truncated > 0)
|
||||||
{
|
{
|
||||||
fprintf (stderr, "\nOversized line detected! Truncated %" PRIu64 " bytes\n", (u64) line_truncated);
|
fprintf (stderr, "\nOversized line detected! Truncated %" PRIu64 " bytes\n", (u64) line_truncated);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
if (line_len == 0) return 0;
|
|
||||||
|
|
||||||
while (line_len)
|
|
||||||
{
|
{
|
||||||
if (line_buf[line_len - 1] == '\n')
|
while (line_len > 0 && line_buf[line_len - 1] == '\r')
|
||||||
{
|
{
|
||||||
line_len--;
|
line_len--;
|
||||||
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (line_buf[line_len - 1] == '\r')
|
|
||||||
{
|
|
||||||
line_len--;
|
|
||||||
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
line_buf[line_len] = 0;
|
line_buf[line_len] = 0;
|
||||||
|
Loading…
Reference in New Issue
Block a user