Index | Thread | Search

From:
"Ted Unangst" <tedu@tedunangst.com>
Subject:
Re: ksh signed overflow
To:
tech@openbsd.org
Date:
Sun, 22 Jun 2025 23:40:48 -0400

Download raw body.

Thread
On 2025-06-22, Ted Unangst wrote:
> Index: table.h
> ===================================================================
> RCS file: /home/cvs/src/bin/ksh/table.h,v
> diff -u -p -r1.15 table.h
> --- table.h	18 Jun 2018 17:03:58 -0000	1.15
> +++ table.h	23 Jun 2025 03:10:56 -0000
> @@ -20,6 +20,7 @@ struct tbl {			/* table item */
>  	union {
>  		char *s;	/* string */
>  		int64_t i;	/* integer */
> +		uint64_t u;	/* unsigned integer */

This is the magic that makes it work, but I'm not sure if this is itself
undefined behavior? What's the latest word on union accesses?

Otherwise the fix would be to add a bunch of casts.