[riot-notifications] [RIOT-OS/RIOT] gnrc_sock_tcp: add gnrc sock tcp (#16494)

benpicco notifications at github.com
Sat Aug 14 14:39:23 CEST 2021


@benpicco commented on this pull request.



> +
+    /* Map SOCK_NO_TIMEOUT to 0. 0 is used in GNRC_TCP for no timeout */
+    if (timeout == SOCK_NO_TIMEOUT) {
+        timeout = 0;
+    }
+
+    /* Forward call to gnrc_tcp_recv: All error codes share the same semantics */
+    return gnrc_tcp_recv(sock, data, max_len, timeout);
+}
+
+ssize_t sock_tcp_write(sock_tcp_t *sock, const void *data, size_t len)
+{
+    /* Asserts defined by API. */
+    assert(sock != NULL);
+    assert(data != NULL);
+    assert(len > 0);

> The entire use case is nonsense and i am not sure is gnrc_tcp handles it correctly.

I can easily imagine a loop like

```C
int res;
while ((res = gnrc_tcp_recv(tcb, data, data_len, 0) {
    data += res;
    data_len -= res;
}
```
That shouldn't trigger an assertion when `data_len` reaches 0. Same for `gnrc_tcp_send()`.

The API also does not specify that the number of bytes to those functions must not be zero.

On Linux I can `read()` 0 bytes without causing a kernel panic :wink: 

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/RIOT-OS/RIOT/pull/16494#discussion_r688926068
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20210814/37a6e9a9/attachment-0001.htm>


More information about the notifications mailing list