getopt: fix null pointer arithmetic ub
authorAlexey Izbyshev <izbyshev@ispras.ru>
Fri, 10 Mar 2023 17:00:31 +0000 (20:00 +0300)
committerRich Felker <dalias@aerifal.cx>
Tue, 11 Apr 2023 13:18:38 +0000 (09:18 -0400)
commit6d322159c633050a405b03b927db76b89e402014
tree3c8fe56b45f18e2a80fcda63f854ee6fef3b2703
parent35e9831156efc1b54e1a91917ba0f787d5df3353
getopt: fix null pointer arithmetic ub

When an option that requires an argument is the last character of
argv[argc-1], getopt computes argv[argc] + optpos. While optpos
is always zero in this case, adding it to null pointer is still
undefined.
src/misc/getopt.c