]> Savannah Git Hosting - gnulib.git/commit
sigsegv: avoid unlikely undefined behavior
authorPaul Eggert <eggert@cs.ucla.edu>
Thu, 20 Jun 2024 04:19:42 +0000 (00:19 -0400)
committerPaul Eggert <eggert@cs.ucla.edu>
Thu, 20 Jun 2024 04:20:54 +0000 (00:20 -0400)
commit459da066b3b4fce2dc6cdfa09840508d5de729d8
tree057e4b3b3cdef40fedf8c24a137462193c7775eb
parent572d2511a00bb6a608517c4975ee7ad693218c61
sigsegv: avoid unlikely undefined behavior

Problem found by Coverity for diffutils and reported by Wasser Mai in:
https://bugs.gnu.org/71535
* lib/stackvma.c (rof_open) [__linux__ || __FreeBSD__ || etc]:
Don’t assume result of ‘read’ fits in int.
Avoid undefined behavior if ‘n + MIN_LEFTOVER’ would overflow.
Also, move a test to be after an (n == 0) test, to help the compiler.
ChangeLog
lib/stackvma.c