Permalink
Browse files

fix recently introduced bugs

  • Loading branch information...
1 parent 8e1782a commit 4cec8da3be7b49ccf58b0a4c6609d788fdf4a281 @bwalex committed Jul 22, 2011
Showing with 21 additions and 4 deletions.
  1. +2 −0 crypto.c
  2. +19 −4 tcplay.c
View
@@ -134,6 +134,7 @@ tc_encrypt(struct tc_cipher_chain *cipher_chain, unsigned char *key,
/* Deallocate this key, since we won't need it anymore */
free_safe_mem(cipher_chain->key);
+ cipher_chain->key = NULL;
if (err != 0) {
tc_cipher_chain_free_keys(chain_start);
@@ -185,6 +186,7 @@ tc_decrypt(struct tc_cipher_chain *cipher_chain, unsigned char *key,
/* Deallocate this key, since we won't need it anymore */
free_safe_mem(cipher_chain->key);
+ cipher_chain->key = NULL;
if (err != 0) {
tc_cipher_chain_free_keys(chain_start);
View
@@ -372,9 +372,6 @@ process_hdr(const char *dev, unsigned char *pass, int passlen,
return ENOMEM;
}
- if (dhdr)
- free_safe_mem(dhdr);
-
*pinfo = info;
return 0;
@@ -793,10 +790,14 @@ info_map_common(const char *dev, int sflag, const char *sys_dev,
tc_log(1, "Incorrect password or not a TrueCrypt volume\n");
if (info) {
+ if (info->hdr)
+ free_safe_mem(info->hdr);
free_safe_mem(info);
info = NULL;
}
if (hinfo) {
+ if (hinfo->hdr)
+ free_safe_mem(hinfo->hdr);
free_safe_mem(hinfo);
hinfo = NULL;
}
@@ -823,14 +824,24 @@ info_map_common(const char *dev, int sflag, const char *sys_dev,
if (protect_hidden) {
if (adjust_info(info, hinfo) != 0) {
tc_log(1, "Could not protect hidden volume\n");
- if (info)
+ if (info) {
+ if (info->hdr)
+ free_safe_mem(info->hdr);
free_safe_mem(info);
+ }
info = NULL;
+
+ if (hinfo->hdr)
+ free_safe_mem(hinfo->hdr);
free_safe_mem(hinfo);
hinfo = NULL;
goto out;
}
+
+ if (hinfo->hdr)
+ free_safe_mem(hinfo->hdr);
free_safe_mem(hinfo);
+ hinfo = NULL;
}
}
@@ -865,6 +876,8 @@ info_volume(const char *device, int sflag, const char *sys_dev,
if (info != NULL) {
if (interactive)
print_info(info);
+ if (info->hdr)
+ free_safe_mem(info->hdr);
free_safe_mem(info);
return 0;
@@ -894,6 +907,8 @@ map_volume(const char *map_name, const char *device, int sflag,
if ((error = dm_setup(map_name, info)) != 0) {
tc_log(1, "Could not set up mapping %s\n", map_name);
+ if (info->hdr)
+ free_safe_mem(info->hdr);
free_safe_mem(info);
return -1;
}

0 comments on commit 4cec8da

Please sign in to comment.