Yo Greg!

Looks good to me.  Go ahead.

On Wed, 29 Oct 2025 10:48:07 -0400
Greg Troxel <[email protected]> wrote:

> Tests all passed, and I fixed gpsrinex.
> 
> I'll push this in 24h unless someone can explain why it's wrong or
> that we should fix it differently, or right away on positive review.
> 
> commit 52a46358c8af3ee2d93fdfa854abe67277f82a15
> Author: Greg Troxel <[email protected]>
> Date:   Wed Oct 29 10:02:59 2025 -0400
> 
>     libgps/gpsutils.c: Fix ctype(3) UB
>     
>     Rather than assigning char to an int, and risking a value outside
> of the range of unsigned char plus EOF, just use an unsigned char
>     intermediary.
> 
> diff --git a/libgps/gpsutils.c b/libgps/gpsutils.c
> index 926ddf864..34091391a 100644
> --- a/libgps/gpsutils.c
> +++ b/libgps/gpsutils.c
> @@ -312,7 +312,7 @@ double safe_atof(const char *string)
>      bool sign = false, expSign = false;
>      double fraction, dblExp, *d;
>      const char *p;
> -    int c;
> +    unsigned char c;
>      int exp = 0;                // Exponent read from "EX" field.
>      int fracExp = 0;            /* Exponent that derives from the
> fractional
>                                   * part.  Under normal
> circumstatnces, it is @@ -337,7 +337,7 @@ double safe_atof(const char
> *string) while (isspace((int)*p)) {
>          p += 1;
>      }
> -    if (isdigit((int)*p)) {
> +    if (isdigit((unsigned char)*p)) {
>          // ignore
>      } else if ('-' == *p) {
>          sign = true;
> @@ -358,7 +358,7 @@ double safe_atof(const char *string)
>      decPt = -1;
>      for (mantSize = 0; ; mantSize += 1) {
>          c = *p;
> -        if (!isdigit((int)c)) {
> +        if (!isdigit(c)) {
>              if ((c != '.') || (decPt >= 0)) {
>                  break;
>              }
> @@ -434,7 +434,7 @@ double safe_atof(const char *string)
>              }
>              expSign = false;
>          }
> -        while (isdigit((int) *p)) {
> +        while (isdigit((unsigned char) *p)) {
>              exp = exp * 10 + (*p - '0');
>              if (1024 < exp) {
>                  if (true == expSign) {




RGDS
GARY
---------------------------------------------------------------------------
Gary E. Miller Rellim 109 NW Wilmington Ave., Suite E, Bend, OR 97703
        [email protected]  Tel:+1 541 382 8588

            Veritas liberabit vos. -- Quid est veritas?
    "If you can't measure it, you can't improve it." - Lord Kelvin

Attachment: pgpxl3H12eyZt.pgp
Description: OpenPGP digital signature

Reply via email to