[PATCH ucspi-vsock] vsock_open: return fd instead of 0 on success
Previously, this returned the return value of connect(2), which is 0 on success. So stdin would be assigned to descriptors 6 and 7 in vsockclient instead of the socket. Oops. --- vsock.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/vsock.c b/vsock.c index 3bcd8b3..d9ff3b6 100644 --- a/vsock.c +++ b/vsock.c @@ -55,7 +55,10 @@ int vsock_open(uint32_t cid, uint32_t port) if (fd == -1) return -1; - return vsock_connect(fd, cid, port); + if (vsock_connect(fd, cid, port) == -1) + return -1; + + return fd; } int vsock_get_port(int fd, uint32_t *port) -- 2.30.0
On Tue Mar 9, 2021 at 9:18 AM PST, Alyssa Ross wrote:
Previously, this returned the return value of connect(2), which is 0 on success. So stdin would be assigned to descriptors 6 and 7 in vsockclient instead of the socket. Oops. --- vsock.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/vsock.c b/vsock.c index 3bcd8b3..d9ff3b6 100644 --- a/vsock.c +++ b/vsock.c @@ -55,7 +55,10 @@ int vsock_open(uint32_t cid, uint32_t port) if (fd == -1) return -1;
- return vsock_connect(fd, cid, port); + if (vsock_connect(fd, cid, port) == -1) + return -1; + + return fd; }
int vsock_get_port(int fd, uint32_t *port) -- 2.30.0
Hehe, oops indeed.
(Still haven't fixed the indentation issue with aerc... Some day I'll
get around to it...)
Reviewed-by: Cole Helbling
participants (2)
-
Alyssa Ross
-
Cole Helbling