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: NoneSeverity: 3 - Normal
Item Group: Change RequestStatus: None
Privacy: PublicAssigned to: None
Open/Closed: OpenPlanned Release: None
lwIP version: git head

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 Administrator
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
  • -unavailable- added by goldsimon (Posted a comment)
  • -unavailable- added by danielk (Submitted the item)
  •  

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

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    No Changes Have Been Made to This Item

    Back to the top


    Powered by Savane 3.1-cleanup1