[SSSD] [Patch] Cmocka unit test patch for authtok module
Jakub Hrozek
jhrozek at redhat.com
Mon Nov 11 10:47:31 UTC 2013
On Sat, Nov 09, 2013 at 07:29:46PM +0530, Pallavi Jha wrote:
> Hi
>
> I have created the patch and attached it with this mail.
I don't see any attachment, sorry..
> Kindly review it.
> I have commented some of the test as it fails(gives segmentation fault)
> when authtoken is NULL. I think we should test tok for NULL before
> accessing its elements. Please correct me if am wrong.
I think you're right about the additional check, but you can't return
EINVAL, the return value of the functions is a pointer. You could return
NULL as the value instead:
uint8_t *sss_authtok_get_data(struct sss_auth_token *tok)
{
if (!tok) {
return NULL;
}
return tok->data;
}
Feel free to send the additional NULL check as another patch to the
list..
>
> for example :
>
> uint8_t *sss_authtok_get_data(struct sss_auth_token *tok)
> {
> return tok->data;
> }
>
> This should be written as:
>
> uint8_t *sss_authtok_get_data(struct sss_auth_token *tok)
> {
> if(!tok) {
> return EINVAL;
> }
> return tok->data;
> }
More information about the sssd-devel
mailing list