[Date Prev][Date Next]
(ITS#6353) berval->string conversions ignore \0
Full_Name: Hallvard B Furuseth
Version: HEAD, RE24
Submission from: (NULL) (22.214.171.124)
Submitted by: hallvard
Conversion from a binary blob (struct berval*, BerElement read)
to a char* string typically just grabs bv.bv_val even when the
value may contain embedded '\0's.
In these cases, correct operation may require that the conversion
fails if bv_len != (bv_val ? strlen(bv_val) : 0). Or if bv_val is
not \0-terminated, to check if memchr(bv_val, '\0', bv_len) == NULL.
ber_get_stringa, ber_get_stringb, ber_get_bitstringa, ber_scanf "aAv"
Similarly, a lot of code requires a berval to be \0-terminated,
but some also - sometimes unwarranted - also that the first \0
it encounters when walking the value is the terminating \0.
For example, libldap/getdn.c has some exported functions that
look for \0 without checking bv_len, some which checks bv_len but
not a terminating \0, and some which does both. I really don't
know which of these functions can expect there is no embedded \0.
I think we need to introduce 'typedef struct berval BerString',
used to document that bv_len == (bv_val ? strlen(bv_val) : 0) for
the particular berval in question (e.g. in a function prototype).
And maybe a typedef BerData for the opposite.