Can you see the bug? Let’s talk.

Can you see the bug in the code below? Let’s talk. Position in Paris, France. Send your answer to jobs@trust-in-soft.com

#define BUF_LEN 16

unsigned char const gf_wrap = 0x87;

void gf_double(unsigned char *out, unsigned char *in)
{
    unsigned char *p = in + (BUF_LEN - 1);
    unsigned char carry = (in[0] >> 7) ? gf_wrap : 0;

    out += (BUF_LEN - 1);
    for (;;) {
        *out-- = (*p << 1) ^ carry;
        if (p == in) {
            break;
        }
        carry = *p-- >> 7;
    }
}

int main(void)
{
    unsigned char buf_out[BUF_LEN];
    unsigned char buf_in[BUF_LEN] = {
        0x2b, 0x7e, 0x15, 0x16, 0x28, 0xae, 0xd2, 0xa6,
        0xab, 0xf7, 0x15, 0x88, 0x09, 0xcf, 0x4f, 0x3c
    };

    gf_double(buf_out, buf_in);

    return 0;
}

To catch the spirit of what we do, here are some suggested readings: