Thanks.  Taken.

https://github.com/quozl/netrek-client-cow/commit/085f709dc5d56cf368d13a8e753b887170ba2547

Should defend against silly data anyhow.

By the way, patches also welcome via GitHub these days.  Less work for
me than taking your attachment and cleaning up the From line before
piping it into "git am".

On Thu, Apr 30, 2020 at 01:16:34PM -0700, Kevin Zheng wrote:
> Hi there,
> 
> netrek.beeseenterprises.com is a Sturgeon public server. Some of the
> bots have amassed very large "Offense" and "Defense" ratings, so much so
> that the player list in netrek-client-cow shows them as garbled characters.
> 
> Further investigation reveals that ftoa() is not designed to emit
> negative numbers properly, and that for some reason, the client tries to
> call ftoa() on a negative number when displaying these bots' ratings.
> 
> The attached patch replaces the garbled characters with '??????'.
> Further investigation is needed to root cause the problem. It's unclear
> whether or not this is a problem with the server.
> 
> Regards,
> Kevin
> 
> -- 
> Kevin Zheng
> kevinz5000 at gmail.com | kevinz at berkeley.edu
> XMPP: kevinz at eecs.berkeley.edu

> >From a94779b57f87cfcea0f8243e1620018d2e79b082 Mon Sep 17 00:00:00 2001
> From: Kevin Zheng <kevinz5000 at gmail.com>
> Date: Tue, 21 Apr 2020 21:56:03 -0700
> Subject: [PATCH] Emit '?' if ftoa() is given a negative fval
> 
> ---
>  string_util.c | 8 ++++++++
>  string_util.h | 1 +
>  2 files changed, 9 insertions(+)
> 
> diff --git a/string_util.c b/string_util.c
> index 43e81de..57122f6 100644
> --- a/string_util.c
> +++ b/string_util.c
> @@ -53,6 +53,14 @@ char   *ftoa(float fval, char *result, int pad, int iprec, int dprec)
>    int     i, ival;
>    float   val = fval;
>  
> +  if (fval < 0) {
> +    for (i = 0; i <= iprec + dprec + 1; i++) {
> +       result[i] = '?';
> +    }
> +    result[iprec + dprec + 1] = '\0';
> +    return result;
> +  }
> +
>    if ((iprec + dprec) != 0)
>      result[iprec + dprec + 1] = '\0';
>  
> diff --git a/string_util.h b/string_util.h
> index 1a1cc39..f9120fc 100644
> --- a/string_util.h
> +++ b/string_util.h
> @@ -20,6 +20,7 @@ char *itoapad (int val, char *result, int pad, int prec);
>     (if pad is false).
>     
>     WARNING: val must be <= 100000000 (size < 9).
> +   Does not work for negative numbers.
>  */
>  
>  
> -- 
> 2.24.0
> 

> _______________________________________________
> netrek-dev mailing list
> netrek-dev at us.netrek.org
> http://mailman.us.netrek.org/mailman/listinfo/netrek-dev


-- 
James Cameron
http://quozl.netrek.org/