Repository navigation
Commit 2e7730e
Oleksii Molchanov
Add a test that a nextnonce does not strand the nonce it replaces.
Covers the free added to auc_digest_info(). The test drives the public
client API - auc_challenge(), auc_credentials(), auc_info() - and
asserts on the authenticator's own allocation statistics rather than on
any internal pointer, because what is being tested is a lifetime and
not a value.
One Authentication-Info is fed first, so that whatever the first update
allocates is already accounted for; the assertion is then that a
hundred further updates leave the number of live blocks unchanged.
Measured on this test:
with the fix live blocks 0 -> 0 bytes 15 -> 15
without it live blocks 1 -> 101 bytes 22 -> 2222
One block per update, and 2 200 bytes for a hundred of them - 22 bytes
each, which is exactly the nonce string in the fixture plus its
terminator.
Three things about the test worth stating, because all three are easy
to get wrong:
The statistics have to be taken from the authenticator's own home, not
from the home handed to auc_challenge(). ca_create() makes the
authenticator a su_home_clone() of that home, and su_home_get_stats()
reports only the home it is given - it does not aggregate clones,
regardless of its include_clones argument. Reading the parent shows
nothing whether the nonce is freed or not.
With the fix in place both block counts are zero, so an assertion on
their equality alone would also hold if the statistics were not being
collected at all. The test therefore checks first that the instrument
reads something (hsb_bytes > 0), and then that the surviving nonce is
the one the server sent last - a free of the wrong pointer, or a
missing assignment, would satisfy the count while losing the value.
And a leak checker cannot see this at all: the strings are allocated
from a su_home and stay reachable through the home's block table until
the home is destroyed, so valgrind and the sanitizers report nothing.
The home's own statistics are the only instrument that sees it.1 parent 19d9a65 commit 2e7730e
1 file changed
Lines changed: 123 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
| 74 | + | |
| 75 | + | |
74 | 76 | | |
75 | 77 | | |
76 | 78 | | |
| |||
1299 | 1301 | | |
1300 | 1302 | | |
1301 | 1303 | | |
| 1304 | + | |
| 1305 | + | |
| 1306 | + | |
| 1307 | + | |
| 1308 | + | |
| 1309 | + | |
| 1310 | + | |
| 1311 | + | |
| 1312 | + | |
| 1313 | + | |
| 1314 | + | |
| 1315 | + | |
| 1316 | + | |
| 1317 | + | |
| 1318 | + | |
| 1319 | + | |
| 1320 | + | |
| 1321 | + | |
| 1322 | + | |
| 1323 | + | |
| 1324 | + | |
| 1325 | + | |
| 1326 | + | |
| 1327 | + | |
| 1328 | + | |
| 1329 | + | |
| 1330 | + | |
| 1331 | + | |
| 1332 | + | |
| 1333 | + | |
| 1334 | + | |
| 1335 | + | |
| 1336 | + | |
| 1337 | + | |
| 1338 | + | |
| 1339 | + | |
| 1340 | + | |
| 1341 | + | |
| 1342 | + | |
| 1343 | + | |
| 1344 | + | |
| 1345 | + | |
| 1346 | + | |
| 1347 | + | |
| 1348 | + | |
| 1349 | + | |
| 1350 | + | |
| 1351 | + | |
| 1352 | + | |
| 1353 | + | |
| 1354 | + | |
| 1355 | + | |
| 1356 | + | |
| 1357 | + | |
| 1358 | + | |
| 1359 | + | |
| 1360 | + | |
| 1361 | + | |
| 1362 | + | |
| 1363 | + | |
| 1364 | + | |
| 1365 | + | |
| 1366 | + | |
| 1367 | + | |
| 1368 | + | |
| 1369 | + | |
| 1370 | + | |
| 1371 | + | |
| 1372 | + | |
| 1373 | + | |
| 1374 | + | |
| 1375 | + | |
| 1376 | + | |
| 1377 | + | |
| 1378 | + | |
| 1379 | + | |
| 1380 | + | |
| 1381 | + | |
| 1382 | + | |
| 1383 | + | |
| 1384 | + | |
| 1385 | + | |
| 1386 | + | |
| 1387 | + | |
| 1388 | + | |
| 1389 | + | |
| 1390 | + | |
| 1391 | + | |
| 1392 | + | |
| 1393 | + | |
| 1394 | + | |
| 1395 | + | |
| 1396 | + | |
| 1397 | + | |
| 1398 | + | |
| 1399 | + | |
| 1400 | + | |
| 1401 | + | |
| 1402 | + | |
| 1403 | + | |
| 1404 | + | |
| 1405 | + | |
| 1406 | + | |
| 1407 | + | |
| 1408 | + | |
| 1409 | + | |
| 1410 | + | |
| 1411 | + | |
| 1412 | + | |
| 1413 | + | |
| 1414 | + | |
| 1415 | + | |
| 1416 | + | |
| 1417 | + | |
| 1418 | + | |
| 1419 | + | |
| 1420 | + | |
| 1421 | + | |
| 1422 | + | |
| 1423 | + | |
1302 | 1424 | | |
1303 | 1425 | | |
1304 | 1426 | | |
| |||
1485 | 1607 | | |
1486 | 1608 | | |
1487 | 1609 | | |
| 1610 | + | |
1488 | 1611 | | |
1489 | 1612 | | |
1490 | 1613 | | |
| |||
0 commit comments