A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/python/cpython/commit/1e2ec8a996daec65d8d5a3d43b66a9909c6d0653 below:

Fix unaligned accesses in siphash24(). (GH-6123) · python/cpython@1e2ec8a · GitHub

File tree Expand file treeCollapse file tree 2 files changed

+14

-13

lines changed

Filter options

Expand file treeCollapse file tree 2 files changed

+14

-13

lines changed Original file line number Diff line number Diff line change

@@ -0,0 +1 @@

1 +

Fix unaligned accesses in siphash24(). Patch by Rolf Eike Beer.

Original file line number Diff line number Diff line change

@@ -366,7 +366,7 @@ static PyHash_FuncDef PyHash_Func = {fnv, "fnv", 8 * SIZEOF_PY_HASH_T,

366 366

static uint64_t

367 367

siphash24(uint64_t k0, uint64_t k1, const void *src, Py_ssize_t src_sz) {

368 368

uint64_t b = (uint64_t)src_sz << 56;

369 -

const uint64_t *in = (uint64_t*)src;

369 +

const uint8_t *in = (uint8_t*)src;

370 370 371 371

uint64_t v0 = k0 ^ 0x736f6d6570736575ULL;

372 372

uint64_t v1 = k1 ^ 0x646f72616e646f6dULL;

@@ -375,28 +375,28 @@ siphash24(uint64_t k0, uint64_t k1, const void *src, Py_ssize_t src_sz) {

375 375 376 376

uint64_t t;

377 377

uint8_t *pt;

378 -

uint8_t *m;

379 378 380 379

while (src_sz >= 8) {

381 -

uint64_t mi = _le64toh(*in);

382 -

in += 1;

383 -

src_sz -= 8;

380 +

uint64_t mi;

381 +

memcpy(&mi, in, sizeof(mi));

382 +

mi = _le64toh(mi);

383 +

in += sizeof(mi);

384 +

src_sz -= sizeof(mi);

384 385

v3 ^= mi;

385 386

DOUBLE_ROUND(v0,v1,v2,v3);

386 387

v0 ^= mi;

387 388

}

388 389 389 390

t = 0;

390 391

pt = (uint8_t *)&t;

391 -

m = (uint8_t *)in;

392 392

switch (src_sz) {

393 -

case 7: pt[6] = m[6]; /* fall through */

394 -

case 6: pt[5] = m[5]; /* fall through */

395 -

case 5: pt[4] = m[4]; /* fall through */

396 -

case 4: memcpy(pt, m, sizeof(uint32_t)); break;

397 -

case 3: pt[2] = m[2]; /* fall through */

398 -

case 2: pt[1] = m[1]; /* fall through */

399 -

case 1: pt[0] = m[0]; /* fall through */

393 +

case 7: pt[6] = in[6]; /* fall through */

394 +

case 6: pt[5] = in[5]; /* fall through */

395 +

case 5: pt[4] = in[4]; /* fall through */

396 +

case 4: memcpy(pt, in, sizeof(uint32_t)); break;

397 +

case 3: pt[2] = in[2]; /* fall through */

398 +

case 2: pt[1] = in[1]; /* fall through */

399 +

case 1: pt[0] = in[0]; /* fall through */

400 400

}

401 401

b |= _le64toh(t);

402 402

You can’t perform that action at this time.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4