1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-05-28 21:50:02 +02: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 5999d95e04
commit 509d0f76ce
No known key found for this signature in database
GPG Key ID: E3FDFF218E45B72B

View File

@ -286,7 +286,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);