Re: arc4_getbyte

2021-03-16 Thread Michael Grant via isync-devel
> in fact, it works with any compiler by necessity, as the assignment to char > variables MUST truncate the result. > > the masking in line 12 is necessary, because there is no assignment. > https://stackoverflow.com/questions/46073295/implicit-type-promotion-rules > explains the deeper problem.

Re: arc4_getbyte

2021-03-16 Thread Oswald Buddenhagen
On Tue, Mar 16, 2021 at 05:52:58AM -0400, Michael Grant via isync-devel wrote: I realize they are uchar which means 8 bits and maybe this works fine in gcc, in fact, it works with any compiler by necessity, as the assignment to char variables MUST truncate the result. the masking in line 12

Re: arc4_getbyte

2021-03-16 Thread Michael Grant via isync-devel
> Or maybe even use % 255 instead of a bitmask. I did not test this which is > why this isn't a patch. Oops, it would have to be %256. signature.asc Description: PGP signature ___ isync-devel mailing list isync-devel@lists.sourceforge.net https://lis

arc4_getbyte

2021-03-16 Thread Michael Grant via isync-devel
I was looking at the arc4_getbyte() utility function the other day and I noticed something that struck me as dangerous. 1 uchar 2 arc4_getbyte( void ) 3 { 4uchar si, sj; 5 6rs.i++; 7si = rs.s[rs.i]; 8rs.j += si; 9sj = rs.s[rs.j]; 10 rs.s[rs.i] = sj; 11 rs.s[rs.j] = si