openafs/tests/util
Andrew Deason ec5bcd1a0c util: Avoid bad ascii[1] in volutil_GetPartitionID
If the caller gives "/vicep" or "vicep" to volutil_GetPartitionID(),
we'll strlcpy() an empty string into ascii[], setting ascii[0] to 0.
Then we check the value of ascii[1], which is uninitialized.

This doesn't result in any bad behavior, because we then immediately
check the value of ascii[0] (which is 0), and return -1. But reading
the uninitialized ascii[1] triggers errors in tools like valgrind, and
is possibly fragile for future code changes.

To avoid this, make sure ascii[] is initialized at the start of the
function, and check if we have copied an empty string into ascii[].

While we are here, also add tests in volutil-t for invalid "vicep*"
strings, to match the existing tests for invalid "/vicep*" strings.

Change-Id: I724f893d4bb6421b955c1c89629ab9f277be98bc
Reviewed-on: https://gerrit.openafs.org/15526
Reviewed-by: Benjamin Kaduk <kaduk@mit.edu>
Reviewed-by: Cheyenne Wills <cwills@sinenomine.net>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
2023-09-17 00:46:03 -04:00
..
.gitignore tests: partition name to id function tests 2018-09-14 08:35:18 -04:00
exec-alt-t.c tests: avoid passing NULL strings to vprintf 2016-09-25 18:45:44 -04:00
ktime-t.c tests/util/ktime-t.c: Specify EST offset in TZ 2016-10-10 23:17:26 -04:00
Makefile.in tests: Remove check/test/tests subdir targets 2021-08-26 10:29:57 -04:00
volutil-t.c util: Avoid bad ascii[1] in volutil_GetPartitionID 2023-09-17 00:46:03 -04:00