buglwIP - A Lightweight TCP/IP stack - Bugs: bug #51538, Don't use signed types when...


You are not allowed to post comments on this tracker with your current authentication level.

bug #51538: Don't use signed types when overflow is expected

Submitted by:  Daniel Elstner <danielk>
Submitted on:  Sat 22 Jul 2017 02:02:14 PM UTC  
Category:  None Severity:  3 - Normal
Item Group:  Change Request Status:  Fixed
Privacy:  Public Assigned to:  Simon Goldschmidt <goldsimon>
Open/Closed:  Closed Planned Release:  2.1.0
lwIP version:  git head

Fri 17 Nov 2017 08:39:42 PM UTC, comment #2:

> Can you provide a change that works with -Wconversion?

Obviously not, thanks for the talk ;-)

Reverting the 2 lines in question, I don't have access to a compiler telling me about -Wconversion right now, and it's not that pressing anyway: there are enough files left that don't compile with this setting...

Simon Goldschmidt <goldsimon>
Project AdministratorIn charge of this item.
Mon 24 Jul 2017 06:27:48 PM UTC, comment #1:

Hmm, while the part about the standard is true, I'm not aware of a system where this doesn't work and as such, I didn't pay much attention.

Can you provide a change that works with -Wconversion?

Simon Goldschmidt <goldsimon>
Project AdministratorIn charge of this item.
Sat 22 Jul 2017 02:02:14 PM UTC, original submission:

I just noticed that commit f3c860958fbea544e9e1e4222339a1373dcbf3b6 "-Wconversion (still far from finished) and other minor compilation fixes..." changes some types from unsigned to signed.

Some of these are in code I wrote in sntp.c:

The problem with these changes is that according to the C standard, any overflow resulting from calculations on signed integer types leads to undefined behavior. That is the reason why I put these convoluted casts to and from unsigned in the code; as for unsigned integer types the C standard defines modulo behavior in case of overflow.

The use of time_t in the calculations could also lead to wrong results due to sign extension on platforms where time_t is a signed 64-bit integer.

Daniel Elstner <danielk>


No files currently attached


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by goldsimon (Posted a comment)
  • -email is unavailable- added by danielk (Submitted the item)

    Do you think this task is very important?
    If so, you can add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.




    Follow 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2017-11-17 goldsimon StatusNone => Fixed
        Assigned toNone => goldsimon
        Open/ClosedOpen => Closed
    2017-11-17 goldsimon Planned ReleaseNone => 2.1.0

    Back to the top

    Powered by Savane 3.3