# --- T2-COPYRIGHT-BEGIN --- # t2/package/*/xinetd/hotfix-sio.patch.uclibc # Copyright (C) 2026 The T2 SDE Project # SPDX-License-Identifier: GPL-2.0 or patched project license # --- T2-COPYRIGHT-END --- --- /tmp/sprint.c.orig 2026-06-27 11:33:15.594000000 +0200 +++ xinetd-2.3.15.4/src/sio/sprint.c 2026-06-27 11:32:11.773000000 +0200 @@ -163,91 +163,24 @@ */ static char *conv_fp( char format, double num, boolean_e add_dp, int precision, bool_int *is_negative, char buf[], ssize_t *len ) - /* always add decimal point if YES */ { - char *s = buf ; - char *p = NULL ; - int decimal_point ; - + char tmp[MAX_FLOAT_DIGITS + 32]; + char fmt[16]; + if ( precision > MAX_FLOAT_DIGITS ) precision = MAX_FLOAT_DIGITS ; - if ( format == 'f' ) - p = (char *)fcvt( num, precision, &decimal_point, is_negative ) ; - else /* either e or E format */ - p = (char *)ecvt( num, precision+1, &decimal_point, is_negative ) ; - - /* - * Check for Infinity and NaN - */ - if ( isalpha( *p ) ) - { - *len = strlen( strcpy( buf, p ) ) ; - *is_negative = FALSE ; - return( buf ) ; + snprintf( fmt, sizeof fmt, "%s%%.%d%c", add_dp ? "#" : "", precision, format ); + snprintf( tmp, sizeof tmp, fmt, num ); + if ( tmp[0] == '-' ) { + *is_negative = TRUE; + strcpy( buf, tmp + 1 ); + } else { + *is_negative = FALSE; + strcpy( buf, tmp ); } - - if ( format == 'f' ) - if ( decimal_point <= 0 ) - { - *s++ = '0' ; - if ( precision > 0 ) - { - *s++ = '.' ; - while ( decimal_point++ < 0 ) - *s++ = '0' ; - } - else if ( add_dp ) - *s++ = '.' ; - } - else - { - while ( decimal_point-- > 0 ) - *s++ = *p++ ; - if ( precision > 0 || add_dp ) *s++ = '.' ; - } - else - { - *s++ = *p++ ; - if ( precision > 0 || add_dp ) *s++ = '.' ; - } - - /* - * copy the rest of p, the NUL is NOT copied - */ - while ( *p ) *s++ = *p++ ; - - if ( format != 'f' ) - { - char temp[ EXPONENT_LENGTH ] ; /* for exponent conversion */ - ssize_t t_len ; - bool_int exponent_is_negative ; - - *s++ = format ; /* either e or E */ - decimal_point-- ; - if ( decimal_point != 0 ) - { - p = conv_10( (wide_int)decimal_point, FALSE, &exponent_is_negative, - &temp[ EXPONENT_LENGTH ], &t_len ) ; - *s++ = exponent_is_negative ? '-' : '+' ; - - /* - * Make sure the exponent has at least 2 digits - */ - if ( t_len == 1 ) - *s++ = '0' ; - while ( t_len-- ) *s++ = *p++ ; - } - else - { - *s++ = '+' ; - *s++ = '0' ; - *s++ = '0' ; - } - } - - *len = s - buf ; - return( buf ) ; + *len = strlen( buf ); + return( buf ); }