Re: UBSAN error in lib/sh/random.c:79

2023-01-07 Thread Steffen Nurpmeso
Andreas Schwab wrote in <871qo6f90g@igel.home>: |On Jan 07 2023, Greg Wooledge wrote: |> The variable l is a modulus, so its largest possible value is 127772. |> If the code simply said "l = ret % 127773;" then it wouldn't even be |> an issue. But the % was rewritten, presumably for effic

Re: UBSAN error in lib/sh/random.c:79

2023-01-07 Thread Andreas Schwab
On Jan 07 2023, Greg Wooledge wrote: > The variable l is a modulus, so its largest possible value is 127772. > If the code simply said "l = ret % 127773;" then it wouldn't even be > an issue. But the % was rewritten, presumably for efficiency. Presumably the assumption was that two divides are m

Re: UBSAN error in lib/sh/random.c:79

2023-01-07 Thread Andreas Schwab
On Jan 07 2023, Martin Schulte wrote: > Hello! > > Am Sat, 07 Jan 2023 19:08:06 +0100 schrieb Andreas Schwab > : > >> On Jan 07 2023, Greg Wooledge wrote: >> ... >> I think the original overflow can only happen if the argument of >> intrand32 is bigger than INT_MAX. > > Question might be if an ov

Re: UBSAN error in lib/sh/random.c:79

2023-01-07 Thread Martin Schulte
Hello! Am Sat, 07 Jan 2023 19:08:06 +0100 schrieb Andreas Schwab : > On Jan 07 2023, Greg Wooledge wrote: > ... > I think the original overflow can only happen if the argument of > intrand32 is bigger than INT_MAX. Question might be if an overflow does any harm - or maybe even is intended... B

Re: UBSAN error in lib/sh/random.c:79

2023-01-07 Thread Greg Wooledge
On Sat, Jan 07, 2023 at 07:08:06PM +0100, Andreas Schwab wrote: > On Jan 07 2023, Greg Wooledge wrote: > > > I think this patch might be correct: > > > > > > --- lib/sh/random.c.orig2023-01-07 12:26:09.049950519 -0500 > > +++ lib/sh/random.c 2023-01-07 12:26:27.469974730 -0500 > > @@ -70,8 +70

Re: UBSAN error in lib/sh/random.c:79

2023-01-07 Thread Andreas Schwab
On Jan 07 2023, Greg Wooledge wrote: > I think this patch might be correct: > > > --- lib/sh/random.c.orig 2023-01-07 12:26:09.049950519 -0500 > +++ lib/sh/random.c 2023-01-07 12:26:27.469974730 -0500 > @@ -70,8 +70,8 @@ > There are lots of other combinations of constants to use; look

Re: UBSAN error in lib/sh/random.c:79

2023-01-07 Thread Greg Wooledge
On Fri, Jan 06, 2023 at 09:00:30PM -0500, Greg Wooledge wrote: > On Sat, Jan 07, 2023 at 01:37:30AM +, Sam James wrote: > > random.c:79:21: runtime error: signed integer overflow: 31789 * 127773 > > cannot be represented in type 'int' > > #0 0x559791a301ce in intrand32 > > /usr/src/debug/

Re: printf %n is not documented

2023-01-07 Thread Emanuele Torre
On Sat, Jan 07, 2023 at 03:00:58PM +0100, felix wrote: >strU8DiffLen0() { local _cLen=${#1} LC_ALL=C;return $((${#1}-_cLen));} Do not use `return' like that. `return' is used to make functions report an exit status: 0 for success, non-zero for various kinds of failure, just like executable pr

Re: printf %n is not documented

2023-01-07 Thread felix
My two cents: Le Tue, Dec 27, 2022 at 03:44:29PM -0500, Chet Ramey a écrit : > > So maybe the better thing to do is to list the set of valid format > specifiers from the standard printf(3) set. > I'm not a C programmer, so I didn't hear about `printf %n` before this thread. Re-reading all `man {