bugGPSD - Bugs: bug #50602, ppsthread.c segfault on 32bit with...

 
 

bug #50602: ppsthread.c segfault on 32bit with -D 4 debugging

Submitted by:  None
Submitted on:  Tue 21 Mar 2017 02:52:09 PM UTC  
 
Category: NoneSeverity: 3 - Normal
Item Group: NoneStatus: Fixed
Privacy: PublicAssigned to: None
Open/Closed: Closed

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Tue 21 Mar 2017 07:26:59 PM UTC, comment #1:

Sorry I meant %lld ;-)

Anonymous
Tue 21 Mar 2017 02:52:09 PM UTC, original submission:

Hi,

I found and fixed a segfault on gpsd-3.16. It happens if the software is compiled for a 32 bit platform (an i.MX6 running buildroot), a PPS source is used, and logging is active.

How to reproduce:
- Compile and run gpsd-3.16 on a 32 bit platform
- Run with: -D 4 and attach a PPS source (ktimer is sufficient)
- Here: "gpsd -n -N -D4 /dev/ttymxc1 /dev/pps1"
- The gpsd will crash with a segfault in less than one second, but only for loglevels higher or equal than 4.

Reason:
- In file ppsthread.c some local variables are of type "long long", esp "cycle" and "duration". Unfortunately, the format strings of the respective logging output specifies %d and %7d, which does not reflect a "long long" on a 32 bit ARM CPU. The correct format string is %lld. As the sizes are wrong here, the wrong amount of bytes are assumed on the stack and later string-based variables referred by the format strings are represented by wrong pointers resulting in a segmentation fault.

Fix:
- Change all %d and %7d to %ldd if "long long" variables are referred to.
- Check these lines: 776 (2x), 843 (2x), 901 (2x)

After fixing this, gpsd works well without segfaulting.

Regards,
Florian

Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

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 esr (Updated 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):

     

     

    Follow 2 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Thu 07 Sep 2017 04:31:49 AM UTCesrOpen/ClosedOpen=>Closed
    Wed 06 Sep 2017 10:47:44 AM UTCesrStatusNone=>Fixed

    Back to the top


    Powered by Savane 3.1-cleanup1