diff options
author | Greg Hudson <ghudson@mit.edu> | 2013-04-08 15:32:31 -0400 |
---|---|---|
committer | Greg Hudson <ghudson@mit.edu> | 2013-04-08 15:32:31 -0400 |
commit | 31124ffb81e8c0935403a9fdc169dead5ecaa777 (patch) | |
tree | 837d49e7ef8de324f8ad288ab3231ca2acdcdbd7 /src/lib/krb5/krb/authdata.c | |
parent | caaf72893a5be61822763eb471f4d573992479ed (diff) | |
download | krb5-31124ffb81e8c0935403a9fdc169dead5ecaa777.zip krb5-31124ffb81e8c0935403a9fdc169dead5ecaa777.tar.gz krb5-31124ffb81e8c0935403a9fdc169dead5ecaa777.tar.bz2 |
Avoid passing null pointers to memcpy/memcmp
By a strict reading of the C standard, memcpy and memcmp have
undefined behavior if their pointer arguments aren't valid object
pointers, even if the length argument is 0. Compilers are becoming
more aggressive about breaking code with undefined behavior, so we
should try to avoid it when possible.
In a krb5_data object, we frequently use NULL as the data value when
the length is 0. Accordingly, we should avoid copying from or
comparing the data field of a length-0 krb5_data object. Add checks
to our wrapper functions (like data_eq and k5_memdup) and to code
which works with possibly-empty krb5_data objects. In a few places,
use wrapper functions to simplify the code rather than adding checks.
Diffstat (limited to 'src/lib/krb5/krb/authdata.c')
-rw-r--r-- | src/lib/krb5/krb/authdata.c | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/src/lib/krb5/krb/authdata.c b/src/lib/krb5/krb/authdata.c index 546fb82..75b1c6e 100644 --- a/src/lib/krb5/krb/authdata.c +++ b/src/lib/krb5/krb/authdata.c @@ -292,8 +292,7 @@ k5_ad_find_module(krb5_context kcontext, continue; /* check for name match */ - if (strlen(module->name) != name->length || - memcmp(module->name, name->data, name->length) != 0) + if (!data_eq_string(*name, module->name)) continue; ret = module; |