On Ubuntu 24-04/Noble:
# gcc --version
gcc (Ubuntu 13.2.0-23ubuntu4) 13.2.0
                ...

#gcc -Wno-parentheses -Wno-dangling-else -c rda.c -O -o /dev/null
In file included from /usr/include/features.h:502,
                 from os.h:12,
                 from exim.h:38,
                 from rda.c:15:
In function ‘read’, inlined from ‘rda_read_string’ at rda.c:474:7:
/usr/include/x86_64-linux-gnu/bits/unistd.h:28:10: warning: ‘__read_alias’ specified size 18446744073709551615 exceeds maximum object size 9223372036854775807 [-Wstringop-overflow=]
   28 |   return __glibc_fortify (read, __nbytes, sizeof (char),
      |          ^~~~~~~~~~~~~~~
/usr/include/x86_64-linux-gnu/bits/unistd-decl.h: In function ‘rda_read_string’:
/usr/include/x86_64-linux-gnu/bits/unistd-decl.h:29:16: note: in a call to function ‘__read_alias’ declared with attribute ‘access (write_only, 2, 3)’ 29 | extern ssize_t __REDIRECT_FORTIFY (__read_alias, (int __fd, void *__buf,
      |                ^~~~~~~~~~~~~~~~~~

rda.c:474 before macro expansion is
 if (read(fd, *sp = store_get(len, GET_UNTAINTED), len) != len) return FALSE;


18446744073709551615 = 2^64 -1 = SIZE_MAX
 9223372036854775807 = 2^63 -1 = SSIZE_MAX

 From man read:
     According to POSIX.1, if count is greater than SSIZE_MAX, the
     result  is implementation-defined; see NOTES for the upper limit on Linux.

     On Linux, read() (and  similar  system  calls)  will  transfer  at
     most 0x7ffff000 (2,147,479,552) bytes, returning the number of bytes
     actually transferred.  (This is true on both 32-bit and 64-bit systems.)

The attached patch removes the warning by moving the assignment to *sp
out of (before) the call to read.
Can anyone see what is going on and whether this is an appropriate fix ?

Oh, without the optimizing option '-O' there is no warning !

Thanks,

--
Andrew C. Aitchison                      Kendal, UK
                   [email protected]

--
## subscription configuration (requires account):
##   https://lists.exim.org/mailman3/postorius/lists/exim-dev.lists.exim.org/
## unsubscribe (doesn't require an account):
##   [email protected]
## Exim details at http://www.exim.org/
## Please use the Wiki with this list - http://wiki.exim.org/

Reply via email to