In article <[email protected]>
[email protected] (Hal Murray) writes:
>In article <[email protected]>,
> Harlan Stenn <[email protected]> writes:
>>I'm glad it is working for you and I'd be even happier if we could figure
>>out why the NULL string got where it did earlier, as ntpd should never drop
>>core like that.
>
>It might be just a simple bug. The code in that area says:
>
> if ((len = readlink(device,buffer,sizeof(buffer))) == -1)
> return(0);
> buffer[len] = 0;
>
> if ((nmea_host = strtok(buffer,":")) == NULL)
> return(0);
>
> nmea_port = atoi(strtok(NULL,":"));
>
>The idea is that if you are using the nmead, then /dev/gps0
>will be a synbilic link to someting like "server:port" so
>nmea_host will be the server and nmea_port will be the port number.
And if it isn't, but rather a link to (say) /dev/ttyS0, nmea_host will
get the whole "/dev/ttyS0" (the first "colon-separated token"), the
second strtok() will return NULL since there are no more "tokens", and
atoi(NULL) shouldn't be expected to do anything more meaningful than
crash. Better code would be
char *p;
...
if ((p = strtok(NULL,":")) == NULL)
return 0;
nmea_port = atoi(p);
--Per Hedeland
[email protected]
_______________________________________________
questions mailing list
[email protected]
https://lists.ntp.org/mailman/listinfo/questions