sockets.c: fix crash when handling invalid/unsupported FDs
aee924b [0] introduce a bug where any return value of sock_net_file_get
that is an error code but *not -EBADF* will return in a crash.
Assume a situation where sock_net_file_get(i) returns an error-encoded
file that is not -EBADF (e.g., -EINVAL): that file will go through the
if (PTR2ERR(file) == -EBADF)
check and pass it, moving on to
if (maxfd < file->sock_fd)
where the error-encoded pointer is dereferenced, resulting in a crash.
[0] https://github.com/hlef/lib-lwip/commit/
aee924ba854034f8b085a4298
Signed-off-by: Hugo Lefeuvre <hugo.lefeuvre@manchester.ac.uk>
Reviewed-by: Cezar Craciunoiu <cezar.craciunoiu@gmail.com>
Approved-by: Simon Kuenzer <simon.kuenzer@neclab.eu>
Tested-by: Unikraft CI <monkey@unikraft.io>
GitHub-Pull-Request: #14