lwip-devel
[Top][All Lists]
Advanced

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

[lwip-devel] [bug #53200] Suspect issue with iphdr in ip4_output_if_opt_


From: Brian
Subject: [lwip-devel] [bug #53200] Suspect issue with iphdr in ip4_output_if_opt_src() (Causing a stack corruption)
Date: Wed, 21 Feb 2018 01:36:14 -0500 (EST)
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.167 Safari/537.36

URL:
  <http://savannah.nongnu.org/bugs/?53200>

                 Summary: Suspect issue with iphdr in ip4_output_if_opt_src()
(Causing a stack corruption)
                 Project: lwIP - A Lightweight TCP/IP stack
            Submitted by: mofosyne
            Submitted on: Wed 21 Feb 2018 06:36:12 AM UTC
                Category: IPv4
                Severity: 3 - Normal
              Item Group: Crash Error
                  Status: None
                 Privacy: Public
             Assigned to: None
             Open/Closed: Open
         Discussion Lock: Any
         Planned Release: None
            lwIP version: 2.0.3

    _______________________________________________________

Details:

I was using `-Og` for debugger friendly optimisation level, when previously I
was using `-Os` which worked fine with no issue.

However it led to a stack corruption as soon as it reaches `PH_TOS_SET(iphdr,
tos)` in ip4_output_if_opt_src()

This could be either an issue with my initialisation or with this function.
I'm not yet sure at this stage.

After further probing I found that there is this error message:

```
In file included from ./thirdparty/lwip/src/include/lwip/ip4.h:49:0,
                 from ./thirdparty/lwip/src/include/lwip/ip.h:47,
                 from thirdparty/lwip/src/core/ipv4/ip4.c:45:
thirdparty/lwip/src/core/ipv4/ip4.c: In function 'ip4_output_if_src':
./thirdparty/lwip/src/include/lwip/prot/ip4.h:118:43: error: 'iphdr' may be
used uninitialized in this function [-Werror=maybe-uninitialized]
 #define IPH_TTL_SET(hdr, ttl) (hdr)->_ttl = (u8_t)(ttl)
                                           ^
thirdparty/lwip/src/core/ipv4/ip4.c:823:18: note: 'iphdr' was declared here
   struct ip_hdr *iphdr;
                  ^
cc1: all warnings being treated as errors
make: ***
[build/GRIDTHINGS-CORE-G1-004/debug/./thirdparty/lwip/src/core/ipv4/ip4.o]
Error 1
```

Adding to ip4_output_if_opt_src() in `~/thirdparty/lwip/src/core/ipv4/ip4.c`
stops the stack corruption.

```
  struct ip_hdr iphdr_guard = {0}; // See if this helps stop stack crash when
at gcc debugger friendly optimisation level `-Og`
  struct ip_hdr *iphdr = &iphdr_guard;
```

Still not sure whats the intention of the `struct ip_hdr *iphdr` but just
letting you guys know, while I'll try and understand this function further...
in case you got a idea whats going on here.





    _______________________________________________________

Reply to this item at:

  <http://savannah.nongnu.org/bugs/?53200>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.nongnu.org/




reply via email to

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