lib/krb5: krb5_store_string*() input must be non-NULL
krb5_store_string, krb5_store_stringz, krb5_store_stringnl If the input string is NULL, fail the call with EINVAL. Do not pass the NULL pointer to strlen(). Change-Id: Id87d72e263dde798f300353ec4c1656b310d17a4
This commit is contained in:
@@ -975,6 +975,10 @@ KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
|
|||||||
krb5_store_string(krb5_storage *sp, const char *s)
|
krb5_store_string(krb5_storage *sp, const char *s)
|
||||||
{
|
{
|
||||||
krb5_data data;
|
krb5_data data;
|
||||||
|
|
||||||
|
if (s == NULL)
|
||||||
|
return EINVAL;
|
||||||
|
|
||||||
data.length = strlen(s);
|
data.length = strlen(s);
|
||||||
data.data = rk_UNCONST(s);
|
data.data = rk_UNCONST(s);
|
||||||
return krb5_store_data(sp, data);
|
return krb5_store_data(sp, data);
|
||||||
@@ -1025,9 +1029,13 @@ krb5_ret_string(krb5_storage *sp,
|
|||||||
KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
|
KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
|
||||||
krb5_store_stringz(krb5_storage *sp, const char *s)
|
krb5_store_stringz(krb5_storage *sp, const char *s)
|
||||||
{
|
{
|
||||||
size_t len = strlen(s) + 1;
|
size_t len;
|
||||||
ssize_t ret;
|
ssize_t ret;
|
||||||
|
|
||||||
|
if (s == NULL)
|
||||||
|
return EINVAL;
|
||||||
|
|
||||||
|
len = strlen(s) + 1;
|
||||||
ret = sp->store(sp, s, len);
|
ret = sp->store(sp, s, len);
|
||||||
if(ret < 0)
|
if(ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
@@ -1089,9 +1097,13 @@ krb5_ret_stringz(krb5_storage *sp,
|
|||||||
KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
|
KRB5_LIB_FUNCTION krb5_error_code KRB5_LIB_CALL
|
||||||
krb5_store_stringnl(krb5_storage *sp, const char *s)
|
krb5_store_stringnl(krb5_storage *sp, const char *s)
|
||||||
{
|
{
|
||||||
size_t len = strlen(s);
|
size_t len;
|
||||||
ssize_t ret;
|
ssize_t ret;
|
||||||
|
|
||||||
|
if (s == NULL)
|
||||||
|
return EINVAL;
|
||||||
|
|
||||||
|
len = strlen(s);
|
||||||
ret = sp->store(sp, s, len);
|
ret = sp->store(sp, s, len);
|
||||||
if(ret < 0)
|
if(ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
Reference in New Issue
Block a user