[riot-notifications] [RIOT-OS/RIOT] sock_util: add interface descriptor parsing to str2ep (#14068)

benpicco notifications at github.com
Tue May 19 00:12:57 CEST 2020


@benpicco commented on this pull request.



> +int _parse_netif(sock_udp_ep_t *ep_out, char *netifstart)
+{
+    char *netifend;
+    size_t netiflen;
+    char netifbuf[NETIF_STR_LEN + 1];
+
+    for (netifend = netifstart; *netifend && *netifend != ']';
+         netifend++);
+    netiflen = netifend - netifstart;
+    if (!*netifend || (netiflen >= NETIF_STR_LEN) || (netiflen == 0)) {
+        /* no netif found, bail out */
+        return -EINVAL;
+    }
+    strncpy(netifbuf, netifstart, netiflen);
+    int netif = strtol(netifbuf, NULL, 10);
+    if ((netif > UINT16_MAX) || (netif < 0)) {

```suggestion
    if ((netif > INT16_MAX) || (netif < 0)) {
```

-- 
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/14068#pullrequestreview-413973434
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20200518/0d5ff907/attachment.htm>


More information about the notifications mailing list