1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-12-22 10:19:57 +01:00

gpg-check-pattern: Consider an empty pattern file as valid

* tools/gpg-check-pattern.c (read_file): Check length before calling
fread.
--

The problem with an empty file is that es_fread is called to read one
element of length zero which seems to be undefined behaviour and
results in ENOENT on my test box.
This commit is contained in:
Werner Koch 2024-03-13 15:32:10 +01:00
parent 609b1ec0c6
commit c27534de95
No known key found for this signature in database
GPG Key ID: E3FDFF218E45B72B

View File

@ -285,7 +285,7 @@ read_file (const char *fname, size_t *r_length)
buflen = st.st_size;
buf = xmalloc (buflen+1);
if (es_fread (buf, buflen, 1, fp) != 1)
if (buflen && es_fread (buf, buflen, 1, fp) != 1)
{
log_error ("error reading '%s': %s\n", fname, strerror (errno));
es_fclose (fp);