Re: [Linuxptp-devel] bugs when reading ptp4l configuration files
On Wed, Mar 29, 2023 at 11:30:49AM -0700, Jacob Keller wrote: > This appears to be caused by using a base of 0 to strtol which then > interprets leading 0 numbers as octal. This is probably done in order to > get handling of '0x' prefixed numbers as well, but the leading 0 -> > octal interpretation is much less common. Actually this convention is widely used. After all, strtol is part of the standard C library and has been forever: strtol(): POSIX.1-2001, POSIX.1-2008, C89, C99 SVr4, 4.3BSD. > The manual page does use several '0x' prefixed values but does not seem > to call out octal values or the implicit conversions. Yeah, could be easily added into the doc... Thanks, Richard ___ Linuxptp-devel mailing list Linuxptp-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linuxptp-devel
[Linuxptp-devel] bugs when reading ptp4l configuration files
Hi, I recently discovered a couple of bugs with ptp4l's config reading code: First, the default configuration specifies values for two of the power profile options which are out of INT_MAX range: power_profile.2011.grandmasterTimeInaccuracy and power_profile.2017.totalTimeInaccuracy On systems with 32-bit integers, the 0x value is out of range, and is not allowed. > 0x is an out of range value for option > power_profile.2011.grandmasterTimeInaccuracy at line 44 It seems like fixing this will require adding unsigned support to the config.c I started looking into this but I must have missed something as the initial code I wrote to support this didn't work and it still reported those values as out-of-range... Second, a user reported to me that they had typo'd sanity_freq_limit as: sanity_freq_limit 02 Then the program interprets this as an octal number with the unexpected value of: ptp4l[6627255.634]: config item (null).sanity_freq_limit is 33554432 This appears to be caused by using a base of 0 to strtol which then interprets leading 0 numbers as octal. This is probably done in order to get handling of '0x' prefixed numbers as well, but the leading 0 -> octal interpretation is much less common. The manual page does use several '0x' prefixed values but does not seem to call out octal values or the implicit conversions. Thanks, Jake ___ Linuxptp-devel mailing list Linuxptp-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linuxptp-devel