reyk / httpd

OpenBSD httpd
Other
314 stars 31 forks source link

str_find_aux() might return a negative number #54

Closed lpereira closed 9 years ago

lpereira commented 9 years ago

It might return the return value of match_error(), which returns (-1). This value is then passed to calloc(), which expects a size_t.

reyk commented 9 years ago

Your diff looks correct. But match_error() will also set ms.error to non-NULL so it should enter the error case and not go into the calloc().

lpereira commented 9 years ago

Yes, you're right -- however Coverity was complaining. Also, under OpenBSD, calloc() would most likely return NULL if a negative number were to be passed to the first argument due to overflow protection anyway. But the "fix" is simple enough.