1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-01-08 08:58:00 +00:00

Fix embarrassing goof in memxor at low sizes.

Ahem. Called with size < 16, that could have underrun the internal
counter and looped over all of memory. Fortunately I've so far only
used it for 1024 bytes at a time!
This commit is contained in:
Simon Tatham 2021-02-21 09:23:43 +00:00
parent 08d17140a0
commit f47e351cee

View File

@ -1079,6 +1079,7 @@ void memxor(uint8_t *out, const uint8_t *in1, const uint8_t *in2, size_t size)
switch (size & 15) {
case 0:
while (size >= 16) {
size -= 16;
*out++ = *in1++ ^ *in2++;
case 15: *out++ = *in1++ ^ *in2++;
case 14: *out++ = *in1++ ^ *in2++;
@ -1095,7 +1096,6 @@ void memxor(uint8_t *out, const uint8_t *in1, const uint8_t *in2, size_t size)
case 3: *out++ = *in1++ ^ *in2++;
case 2: *out++ = *in1++ ^ *in2++;
case 1: *out++ = *in1++ ^ *in2++;
size -= 16;
}
}
}