The most correct fix is rather to input sanitize
argv
. Can be as easy as a memchr
search for \0
. Then you need not concern yourself with potential overflows later on.