crypto/ec/curve25519.c:4543: error: BUFFER_OVERRUN_L2
  Offset: [1, 260] Size: 256 by call to `slide`.
Showing all 7 steps of the trace


crypto/ec/curve25519.c:4532:1: Array declaration
4530.    * B is the Ed25519 base point (x,4/5) with x positive.
4531.    */
4532. > static void ge_double_scalarmult_vartime(ge_p2 *r, const uint8_t *a,
4533.                                            const ge_p3 *A, const uint8_t *b)
4534.   {

crypto/ec/curve25519.c:4543:5: Call
4541.       int i;
4542.   
4543.       slide(aslide, a);
            ^
4544.       slide(bslide, b);
4545.   

crypto/ec/curve25519.c:4433:10: <Offset trace>
4431.       }
4432.   
4433.       for (i = 0; i < 256; ++i) {
                 ^
4434.           if (r[i]) {
4435.               for (b = 1; b <= 6 && i + b < 256; ++b) {

crypto/ec/curve25519.c:4433:10: Assignment
  4431.       }
  4432.   
  4433.       for (i = 0; i < 256; ++i) {
                   ^
  4434.           if (r[i]) {
  4435.               for (b = 1; b <= 6 && i + b < 256; ++b) {

crypto/ec/curve25519.c:4423:1: <Length trace>
4421.   #endif
4422.   
4423. > static void slide(signed char *r, const uint8_t *a)
4424.   {
4425.       int i;

crypto/ec/curve25519.c:4423:1: Parameter `*r`
  4421.   #endif
  4422.   
  4423. > static void slide(signed char *r, const uint8_t *a)
  4424.   {
  4425.       int i;

crypto/ec/curve25519.c:4436:21: Array access: Offset: [1, 260] Size: 256 by call to `slide` 
  4434.           if (r[i]) {
  4435.               for (b = 1; b <= 6 && i + b < 256; ++b) {
  4436.                   if (r[i + b]) {
                              ^
  4437.                       if (r[i] + (r[i + b] << b) <= 15) {
  4438.                           r[i] += r[i + b] << b;

static void slide(signed char *r, const uint8_t *a)
{
    int i;
    int b;
    int k;
    for (i = 0; i < 256; ++i) {
        r[i] = 1 & (a[i >> 3] >> (i & 7));
    }
    for (i = 0; i < 256; ++i) {
        if (r[i]) {
            for (b = 1; b <= 6 && i + b < 256; ++b) {
                if (r[i + b]) {
                    if (r[i] + (r[i + b] << b) <= 15) {
                        r[i] += r[i + b] << b;
                        r[i + b] = 0;
                    } else if (r[i] - (r[i + b] << b) >= -15) {
                        r[i] -= r[i + b] << b;
                        for (k = i + b; k < 256; ++k) {
                            if (!r[k]) {
                                r[k] = 1;
                                break;
                            }
                            r[k] = 0;
                        }
                    } else {
                        break;
                    }
                }
            }
        }
    }
}
['static void ge_double_scalarmult_vartime(ge_p2 *r, const uint8_t *a,\n                                         const ge_p3 *A, const uint8_t *b)\n{\n    signed char aslide[256];\n    signed char bslide[256];\n    ge_cached Ai[8];\n    ge_p1p1 t;\n    ge_p3 u;\n    ge_p3 A2;\n    int i;\n    slide(aslide, a);\n    slide(bslide, b);\n    ge_p3_to_cached(&Ai[0], A);\n    ge_p3_dbl(&t, A);\n    ge_p1p1_to_p3(&A2, &t);\n    ge_add(&t, &A2, &Ai[0]);\n    ge_p1p1_to_p3(&u, &t);\n    ge_p3_to_cached(&Ai[1], &u);\n    ge_add(&t, &A2, &Ai[1]);\n    ge_p1p1_to_p3(&u, &t);\n    ge_p3_to_cached(&Ai[2], &u);\n    ge_add(&t, &A2, &Ai[2]);\n    ge_p1p1_to_p3(&u, &t);\n    ge_p3_to_cached(&Ai[3], &u);\n    ge_add(&t, &A2, &Ai[3]);\n    ge_p1p1_to_p3(&u, &t);\n    ge_p3_to_cached(&Ai[4], &u);\n    ge_add(&t, &A2, &Ai[4]);\n    ge_p1p1_to_p3(&u, &t);\n    ge_p3_to_cached(&Ai[5], &u);\n    ge_add(&t, &A2, &Ai[5]);\n    ge_p1p1_to_p3(&u, &t);\n    ge_p3_to_cached(&Ai[6], &u);\n    ge_add(&t, &A2, &Ai[6]);\n    ge_p1p1_to_p3(&u, &t);\n    ge_p3_to_cached(&Ai[7], &u);\n    ge_p2_0(r);\n    for (i = 255; i >= 0; --i) {\n        if (aslide[i] || bslide[i]) {\n            break;\n        }\n    }\n    for (; i >= 0; --i) {\n        ge_p2_dbl(&t, r);\n        if (aslide[i] > 0) {\n            ge_p1p1_to_p3(&u, &t);\n            ge_add(&t, &u, &Ai[aslide[i] / 2]);\n        } else if (aslide[i] < 0) {\n            ge_p1p1_to_p3(&u, &t);\n            ge_sub(&t, &u, &Ai[(-aslide[i]) / 2]);\n        }\n        if (bslide[i] > 0) {\n            ge_p1p1_to_p3(&u, &t);\n            ge_madd(&t, &u, &Bi[bslide[i] / 2]);\n        } else if (bslide[i] < 0) {\n            ge_p1p1_to_p3(&u, &t);\n            ge_msub(&t, &u, &Bi[(-bslide[i]) / 2]);\n        }\n        ge_p1p1_to_p2(r, &t);\n    }\n}', 'static void slide(signed char *r, const uint8_t *a)\n{\n    int i;\n    int b;\n    int k;\n    for (i = 0; i < 256; ++i) {\n        r[i] = 1 & (a[i >> 3] >> (i & 7));\n    }\n    for (i = 0; i < 256; ++i) {\n        if (r[i]) {\n            for (b = 1; b <= 6 && i + b < 256; ++b) {\n                if (r[i + b]) {\n                    if (r[i] + (r[i + b] << b) <= 15) {\n                        r[i] += r[i + b] << b;\n                        r[i + b] = 0;\n                    } else if (r[i] - (r[i + b] << b) >= -15) {\n                        r[i] -= r[i + b] << b;\n                        for (k = i + b; k < 256; ++k) {\n                            if (!r[k]) {\n                                r[k] = 1;\n                                break;\n                            }\n                            r[k] = 0;\n                        }\n                    } else {\n                        break;\n                    }\n                }\n            }\n        }\n    }\n}']