aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2023-06-20 19:01:54 +0200
committerChristian Grothoff <christian@grothoff.org>2023-06-20 19:01:54 +0200
commit913c2ecc76742983ee9d21c257be907cbb537e65 (patch)
tree87e4804e6c7f6bb9c3795c18d0aaa986e7d93a4c
parentb2c046a3f65f823ff6fbfef4f9c96e876aed56dc (diff)
downloadanastasis-913c2ecc76742983ee9d21c257be907cbb537e65.tar.gz
anastasis-913c2ecc76742983ee9d21c257be907cbb537e65.zip
-fix recdoc use-after-free
-rw-r--r--src/lib/anastasis_recovery.c8
-rw-r--r--src/testing/testing_cmd_recover_secret.c14
2 files changed, 16 insertions, 6 deletions
diff --git a/src/lib/anastasis_recovery.c b/src/lib/anastasis_recovery.c
index e844737..f94e946 100644
--- a/src/lib/anastasis_recovery.c
+++ b/src/lib/anastasis_recovery.c
@@ -626,6 +626,7 @@ policy_lookup_cb (void *cls,
626 json_error_t json_error; 626 json_error_t json_error;
627 const json_t *dec_policies; 627 const json_t *dec_policies;
628 const json_t *esc_methods; 628 const json_t *esc_methods;
629 json_t *recovery_document;
629 630
630 r->plo = NULL; 631 r->plo = NULL;
631 switch (http_status) 632 switch (http_status)
@@ -698,7 +699,6 @@ policy_lookup_cb (void *cls,
698 return; 699 return;
699 } 700 }
700 { 701 {
701 json_t *recovery_document;
702 uint32_t be_size; 702 uint32_t be_size;
703 uLongf pt_size; 703 uLongf pt_size;
704 char *pt; 704 char *pt;
@@ -799,7 +799,6 @@ policy_lookup_cb (void *cls,
799 r->ri.secret_name = r->secret_name; 799 r->ri.secret_name = r->secret_name;
800 } 800 }
801 } 801 }
802 json_decref (recovery_document);
803 } 802 }
804 803
805 r->ri.version = dd->version; 804 r->ri.version = dd->version;
@@ -853,6 +852,7 @@ policy_lookup_cb (void *cls,
853 NULL, 852 NULL,
854 0); 853 0);
855 ANASTASIS_recovery_abort (r); 854 ANASTASIS_recovery_abort (r);
855 json_decref (recovery_document);
856 return; 856 return;
857 } 857 }
858 cs->url = GNUNET_strdup (url); 858 cs->url = GNUNET_strdup (url);
@@ -893,6 +893,7 @@ policy_lookup_cb (void *cls,
893 NULL, 893 NULL,
894 0); 894 0);
895 ANASTASIS_recovery_abort (r); 895 ANASTASIS_recovery_abort (r);
896 json_decref (recovery_document);
896 return; 897 return;
897 } 898 }
898 899
@@ -923,6 +924,7 @@ policy_lookup_cb (void *cls,
923 NULL, 924 NULL,
924 0); 925 0);
925 ANASTASIS_recovery_abort (r); 926 ANASTASIS_recovery_abort (r);
927 json_decref (recovery_document);
926 return; 928 return;
927 } 929 }
928 for (unsigned int i = 0; i<r->ri.cs_len; i++) 930 for (unsigned int i = 0; i<r->ri.cs_len; i++)
@@ -943,12 +945,14 @@ policy_lookup_cb (void *cls,
943 NULL, 945 NULL,
944 0); 946 0);
945 ANASTASIS_recovery_abort (r); 947 ANASTASIS_recovery_abort (r);
948 json_decref (recovery_document);
946 return; 949 return;
947 } 950 }
948 } 951 }
949 } 952 }
950 r->pc (r->pc_cls, 953 r->pc (r->pc_cls,
951 &r->ri); 954 &r->ri);
955 json_decref (recovery_document);
952} 956}
953 957
954 958
diff --git a/src/testing/testing_cmd_recover_secret.c b/src/testing/testing_cmd_recover_secret.c
index 35a8580..1f3e832 100644
--- a/src/testing/testing_cmd_recover_secret.c
+++ b/src/testing/testing_cmd_recover_secret.c
@@ -108,13 +108,19 @@ policy_lookup_cb (void *cls,
108{ 108{
109 struct RecoverSecretState *rss = cls; 109 struct RecoverSecretState *rss = cls;
110 110
111 rss->ri = (struct ANASTASIS_RecoveryInformation *) ri;
112 if (NULL == ri) 111 if (NULL == ri)
113 { 112 {
114 GNUNET_break (0); 113 GNUNET_break (0);
115 TALER_TESTING_interpreter_fail (rss->is); 114 TALER_TESTING_interpreter_fail (rss->is);
116 return; 115 return;
117 } 116 }
117 if (0 == ri->cs_len)
118 {
119 GNUNET_break (0);
120 TALER_TESTING_interpreter_fail (rss->is);
121 return;
122 }
123 rss->ri = (struct ANASTASIS_RecoveryInformation *) ri;
118 TALER_TESTING_interpreter_next (rss->is); 124 TALER_TESTING_interpreter_next (rss->is);
119} 125}
120 126
@@ -188,9 +194,9 @@ recover_secret_run (void *cls,
188 194
189 if (NULL != rss->download_reference) 195 if (NULL != rss->download_reference)
190 { 196 {
191 ref = TALER_TESTING_interpreter_lookup_command 197 ref = TALER_TESTING_interpreter_lookup_command (
192 (is, 198 is,
193 rss->download_reference); 199 rss->download_reference);
194 if (NULL == ref) 200 if (NULL == ref)
195 { 201 {
196 GNUNET_break (0); 202 GNUNET_break (0);