yubikey-personalization icon indicating copy to clipboard operation
yubikey-personalization copied to clipboard

multiple potential memory leaks

Open invd opened this issue 4 years ago • 0 comments

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.

  1. 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.

  1. 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.

  1. ykpersonalize.c https://github.com/Yubico/yubikey-personalization/blob/621279725f71720876ec00b21fea91b8b22a92fa/ykpersonalize.c#L244 I think this should likely go through the error handling (although the exit(1) will properly unclaim the memory as well):
			exit_code = 1;
			goto err;

invd avatar Apr 24 '20 22:04 invd