yubikey-personalization
yubikey-personalization copied to clipboard
multiple potential memory leaks
During recent dynamic program analysis of the code, I noticed that there are a number of cases where allocated memory is not correctly free()
'ed. This happens mainly due to suboptimal memory handling in error cases.
The practical impact of the memory leaks is close to zero on normal usage since the command line programs exit after a brief run. As briefly discussed with @nevun, I'm not aware of any security impact.
-
ykpers-args.c
key_tmp
https://github.com/Yubico/yubikey-personalization/blob/621279725f71720876ec00b21fea91b8b22a92fa/ykpers-args.c#L789-L799
calloc()
via prompt_for_data()
, problematic in the return 0;
case.
-
ykpers-args.c
uidtmp
https://github.com/Yubico/yubikey-personalization/blob/621279725f71720876ec00b21fea91b8b22a92fa/ykpers-args.c#L554-L559
calloc()
via prompt_for_data()
, problematic in the return 0;
case.
-
ykpersonalize.c
https://github.com/Yubico/yubikey-personalization/blob/621279725f71720876ec00b21fea91b8b22a92fa/ykpersonalize.c#L244 I think this should likely go through the error handling (although theexit(1)
will properly unclaim the memory as well):
exit_code = 1;
goto err;