Commit 64d10d8
Fix: Bound file-controlled sizes in
index_gt::view walked the memory-mapped levels[] array (sized from the
file's header.size) before the only file-size check, and index_dense::view
formed a matrix_rows*matrix_cols span into the mapping with no bound plus
an unsigned-underflow header guard. A crafted .usearch index over-read the
mapping. Bound the levels region before the offset-precompute loop, bound
the vectors span with a checked multiply, and make the header guard
underflow-safe.
Co-authored-by: Nathan K <professor-moody@users.noreply.github.com>
Co-authored-by: Ash Vardanian <1983160+ashvardanian@users.noreply.github.com>view() (#776)1 parent 810c172 commit 64d10d8
3 files changed
Lines changed: 77 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1428 | 1428 | | |
1429 | 1429 | | |
1430 | 1430 | | |
| 1431 | + | |
| 1432 | + | |
| 1433 | + | |
| 1434 | + | |
| 1435 | + | |
| 1436 | + | |
| 1437 | + | |
| 1438 | + | |
| 1439 | + | |
| 1440 | + | |
| 1441 | + | |
| 1442 | + | |
| 1443 | + | |
| 1444 | + | |
| 1445 | + | |
| 1446 | + | |
| 1447 | + | |
| 1448 | + | |
| 1449 | + | |
| 1450 | + | |
| 1451 | + | |
| 1452 | + | |
| 1453 | + | |
| 1454 | + | |
| 1455 | + | |
| 1456 | + | |
| 1457 | + | |
| 1458 | + | |
| 1459 | + | |
| 1460 | + | |
| 1461 | + | |
| 1462 | + | |
| 1463 | + | |
| 1464 | + | |
| 1465 | + | |
| 1466 | + | |
| 1467 | + | |
| 1468 | + | |
| 1469 | + | |
| 1470 | + | |
| 1471 | + | |
| 1472 | + | |
| 1473 | + | |
| 1474 | + | |
| 1475 | + | |
| 1476 | + | |
| 1477 | + | |
| 1478 | + | |
| 1479 | + | |
| 1480 | + | |
| 1481 | + | |
| 1482 | + | |
| 1483 | + | |
| 1484 | + | |
| 1485 | + | |
| 1486 | + | |
| 1487 | + | |
| 1488 | + | |
| 1489 | + | |
| 1490 | + | |
| 1491 | + | |
1431 | 1492 | | |
1432 | 1493 | | |
1433 | 1494 | | |
| |||
1524 | 1585 | | |
1525 | 1586 | | |
1526 | 1587 | | |
| 1588 | + | |
1527 | 1589 | | |
1528 | 1590 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3970 | 3970 | | |
3971 | 3971 | | |
3972 | 3972 | | |
| 3973 | + | |
| 3974 | + | |
| 3975 | + | |
| 3976 | + | |
3973 | 3977 | | |
3974 | 3978 | | |
3975 | 3979 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1358 | 1358 | | |
1359 | 1359 | | |
1360 | 1360 | | |
| 1361 | + | |
| 1362 | + | |
| 1363 | + | |
| 1364 | + | |
| 1365 | + | |
1361 | 1366 | | |
1362 | 1367 | | |
1363 | 1368 | | |
| |||
1383 | 1388 | | |
1384 | 1389 | | |
1385 | 1390 | | |
1386 | | - | |
| 1391 | + | |
| 1392 | + | |
| 1393 | + | |
| 1394 | + | |
| 1395 | + | |
| 1396 | + | |
1387 | 1397 | | |
1388 | 1398 | | |
1389 | 1399 | | |
| |||
0 commit comments