embeddable-wg-library: do not left shift negative numbers

Otherwise we incur undefined behavior.

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
Jason A. Donenfeld 2018-07-19 19:15:15 +02:00
parent 4349005f4e
commit c61c5a03ee

View file

@ -1593,16 +1593,11 @@ static __attribute__((noinline)) void memzero_explicit(void *s, size_t count)
static void carry(fe o)
{
int i;
int64_t c;
for (i = 0; i < 16; ++i) {
o[i] += (1LL << 16);
c = o[i] >> 16;
o[(i + 1) * (i < 15)] += c - 1 + 37 * (c - 1) * (i == 15);
o[i] -= c << 16;
o[(i + 1) % 16] += (i == 15 ? 38 : 1) * (o[i] >> 16);
o[i] &= 0xffff;
}
memzero_explicit(&c, sizeof(c));
}
static void cswap(fe p, fe q, int b)