lwip-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lwip-devel] [patch #10335] api, sockets: Fix signed overflow check


From: Mingjie Shen
Subject: [lwip-devel] [patch #10335] api, sockets: Fix signed overflow check
Date: Fri, 14 Apr 2023 17:21:48 -0400 (EDT)

URL:
  <https://savannah.nongnu.org/patch/?10335>

                 Summary: api,sockets: Fix signed overflow check
                   Group: lwIP - A Lightweight TCP/IP stack
               Submitter: szsam
               Submitted: Fri 14 Apr 2023 09:21:46 PM UTC
                Category: None
                Priority: 5 - Normal
                  Status: None
                 Privacy: Public
             Assigned to: None
        Originator Email: 
             Open/Closed: Open
         Discussion Lock: Any
         Planned Release: None


    _______________________________________________________

Follow-up Comments:


-------------------------------------------------------
Date: Fri 14 Apr 2023 09:21:46 PM UTC By: Mingjie Shen <szsam>
Signed overflow is undefined behaviour in C/C++.
---
 src/api/sockets.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/api/sockets.c b/src/api/sockets.c
index 929cd652..50365589 100644
--- a/src/api/sockets.c
+++ b/src/api/sockets.c
@@ -1012,7 +1012,7 @@ lwip_recv_tcp(struct lwip_sock *sock, void *mem, size_t
len, int flags)
     } else {
       copylen = (u16_t)recv_left;
     }
-    if (recvd + copylen < recvd) {
+    if (recvd > SSIZE_MAX - copylen) {
       /* overflow */
       copylen = (u16_t)(SSIZE_MAX - recvd);
     }
-- 
2.25.1






    _______________________________________________________
File Attachments:


-------------------------------------------------------
Date: Fri 14 Apr 2023 09:21:46 PM UTC  Name:
0001-api-sockets-Fix-signed-overflow-check.patch  Size: 776B   By: szsam

<http://savannah.nongnu.org/patch/download.php?file_id=54629>

    _______________________________________________________

Reply to this item at:

  <https://savannah.nongnu.org/patch/?10335>

_______________________________________________
Message sent via Savannah
https://savannah.nongnu.org/




reply via email to

[Prev in Thread] Current Thread [Next in Thread]