Kismet Wireless

Kismet Forums

 

Posted by:dragorn
Subject:gpsd.cc: Scan() sometimes fails
Date:15:40:58 30/05/2007

> > I'm using gpsd.cc in my own program. First of all i wanna thank you for the easy to use and free client!
> >
> > But I encountered the following problem:
> > Sometimes Scan() returns 0 because "values.size()" does not equal 2 (line 211). I modified the code to print the "live"-string to stdout. This is what i get (when it fails):
> > GPSD,P=12.345678 12.345678,A=1234.567,V=0.000,M=3
> > /h�@Ah��=��οy�[�@Ah��=�oy�h�ο���ο��v��=����(�οĔ���=▒
> >
>
> That'd be it not finding the end of a string and running away into memory somewhere...

Which looks like it would do, if you print out the bulk string, since I don't concern myself about null-terminating the returned string from read. This typically isn't a problem since the string manip routines are all blocked into using fragments of the buffer, but I'll throw a null terminator onto the end of the read anyhow. Normally the read buffer gets concatenated into a string w/ a fixed length using snprintf which forces a null terminator to be included, so by the time the tokenizer gets it, it's sanitized. If you're printing the raw read buffer, you've got an unterminated blob of memory.

The newcore gpsd code is totally rewritten internally (uses the common ringbuffer code, doesn't do all this nonsense with partial reads and string concatenation) and might be a better place to look.

-m


Reply to this message