aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2020-05-03 20:12:18 +0200
committerChristian Grothoff <christian@grothoff.org>2020-05-03 20:12:18 +0200
commite4aa60fc4eaac55bdfa88c92e8b50a21750ba453 (patch)
treed3093479294bba1487e67dd009c2ceb89a6d7af3
parent1ed77a9f2eb94a37b2571f5b4e9c4d2c5fa4e326 (diff)
downloadexchange-e4aa60fc4eaac55bdfa88c92e8b50a21750ba453.tar.gz
exchange-e4aa60fc4eaac55bdfa88c92e8b50a21750ba453.zip
modify TALER_EXCHANGE_deposits_get() API to avoid NULL pointers and need for deep copies
-rw-r--r--src/include/taler_exchange_service.h16
-rw-r--r--src/lib/exchange_api_deposits_get.c31
-rw-r--r--src/testing/testing_api_cmd_deposits_get.c5
3 files changed, 21 insertions, 31 deletions
diff --git a/src/include/taler_exchange_service.h b/src/include/taler_exchange_service.h
index 320123041..f94b8253d 100644
--- a/src/include/taler_exchange_service.h
+++ b/src/include/taler_exchange_service.h
@@ -1691,22 +1691,22 @@ struct TALER_EXCHANGE_DepositData
1691{ 1691{
1692 1692
1693 /** 1693 /**
1694 * exchange key used to sign, NULL if exchange did not 1694 * exchange key used to sign, all zeros if exchange did not
1695 * yet execute the transaction 1695 * yet execute the transaction
1696 */ 1696 */
1697 const struct TALER_ExchangePublicKeyP *exchange_pub; 1697 struct TALER_ExchangePublicKeyP exchange_pub;
1698 1698
1699 /** 1699 /**
1700 * signature from the exchange over the deposit data, NULL if exchange did not 1700 * signature from the exchange over the deposit data, all zeros if exchange did not
1701 * yet execute the transaction 1701 * yet execute the transaction
1702 */ 1702 */
1703 const struct TALER_ExchangeSignatureP *exchange_sig; 1703 struct TALER_ExchangeSignatureP exchange_sig;
1704 1704
1705 /** 1705 /**
1706 * wire transfer identifier used by the exchange, NULL if exchange did not 1706 * wire transfer identifier used by the exchange, all zeros if exchange did not
1707 * yet execute the transaction 1707 * yet execute the transaction
1708 */ 1708 */
1709 const struct TALER_WireTransferIdentifierRawP *wtid; 1709 struct TALER_WireTransferIdentifierRawP wtid;
1710 1710
1711 /** 1711 /**
1712 * actual or planned execution time for the wire transfer 1712 * actual or planned execution time for the wire transfer
@@ -1714,10 +1714,10 @@ struct TALER_EXCHANGE_DepositData
1714 struct GNUNET_TIME_Absolute execution_time; 1714 struct GNUNET_TIME_Absolute execution_time;
1715 1715
1716 /** 1716 /**
1717 * contribution to the total amount by this coin, NULL if exchange did not 1717 * contribution to the total amount by this coin, all zeros if exchange did not
1718 * yet execute the transaction 1718 * yet execute the transaction
1719 */ 1719 */
1720 const struct TALER_Amount *coin_contribution; 1720 struct TALER_Amount coin_contribution;
1721}; 1721};
1722 1722
1723 1723
diff --git a/src/lib/exchange_api_deposits_get.c b/src/lib/exchange_api_deposits_get.c
index 6a2ad5c3d..004a24d42 100644
--- a/src/lib/exchange_api_deposits_get.c
+++ b/src/lib/exchange_api_deposits_get.c
@@ -146,16 +146,13 @@ handle_deposit_wtid_finished (void *cls,
146 break; 146 break;
147 case MHD_HTTP_OK: 147 case MHD_HTTP_OK:
148 { 148 {
149 struct GNUNET_TIME_Absolute execution_time; 149 struct TALER_EXCHANGE_DepositData dd;
150 struct TALER_Amount coin_contribution;
151 struct TALER_ExchangePublicKeyP exchange_pub;
152 struct TALER_ExchangeSignatureP exchange_sig;
153 struct GNUNET_JSON_Specification spec[] = { 150 struct GNUNET_JSON_Specification spec[] = {
154 GNUNET_JSON_spec_fixed_auto ("wtid", &dwh->depconf.wtid), 151 GNUNET_JSON_spec_fixed_auto ("wtid", &dwh->depconf.wtid),
155 GNUNET_JSON_spec_absolute_time ("execution_time", &execution_time), 152 GNUNET_JSON_spec_absolute_time ("execution_time", &dd.execution_time),
156 TALER_JSON_spec_amount ("coin_contribution", &coin_contribution), 153 TALER_JSON_spec_amount ("coin_contribution", &dd.coin_contribution),
157 GNUNET_JSON_spec_fixed_auto ("exchange_sig", &exchange_sig), 154 GNUNET_JSON_spec_fixed_auto ("exchange_sig", &dd.exchange_sig),
158 GNUNET_JSON_spec_fixed_auto ("exchange_pub", &exchange_pub), 155 GNUNET_JSON_spec_fixed_auto ("exchange_pub", &dd.exchange_pub),
159 GNUNET_JSON_spec_end () 156 GNUNET_JSON_spec_end ()
160 }; 157 };
161 158
@@ -169,14 +166,15 @@ handle_deposit_wtid_finished (void *cls,
169 hr.ec = TALER_EC_DEPOSITS_INVALID_BODY_BY_EXCHANGE; 166 hr.ec = TALER_EC_DEPOSITS_INVALID_BODY_BY_EXCHANGE;
170 break; 167 break;
171 } 168 }
172 dwh->depconf.execution_time = GNUNET_TIME_absolute_hton (execution_time); 169 dwh->depconf.execution_time = GNUNET_TIME_absolute_hton (
170 dd.execution_time);
173 TALER_amount_hton (&dwh->depconf.coin_contribution, 171 TALER_amount_hton (&dwh->depconf.coin_contribution,
174 &coin_contribution); 172 &dd.coin_contribution);
175 if (GNUNET_OK != 173 if (GNUNET_OK !=
176 verify_deposit_wtid_signature_ok (dwh, 174 verify_deposit_wtid_signature_ok (dwh,
177 j, 175 j,
178 &exchange_pub, 176 &dd.exchange_pub,
179 &exchange_sig)) 177 &dd.exchange_sig))
180 { 178 {
181 GNUNET_break_op (0); 179 GNUNET_break_op (0);
182 hr.http_status = 0; 180 hr.http_status = 0;
@@ -184,14 +182,7 @@ handle_deposit_wtid_finished (void *cls,
184 } 182 }
185 else 183 else
186 { 184 {
187 struct TALER_EXCHANGE_DepositData dd = { 185 dd.wtid = dwh->depconf.wtid;
188 .exchange_pub = &exchange_pub,
189 .exchange_sig = &exchange_sig,
190 .wtid = &dwh->depconf.wtid,
191 .execution_time = execution_time,
192 .coin_contribution = &coin_contribution
193 };
194
195 dwh->cb (dwh->cb_cls, 186 dwh->cb (dwh->cb_cls,
196 &hr, 187 &hr,
197 &dd); 188 &dd);
diff --git a/src/testing/testing_api_cmd_deposits_get.c b/src/testing/testing_api_cmd_deposits_get.c
index 6f0140116..33987e161 100644
--- a/src/testing/testing_api_cmd_deposits_get.c
+++ b/src/testing/testing_api_cmd_deposits_get.c
@@ -111,8 +111,7 @@ deposit_wtid_cb (void *cls,
111 switch (hr->http_status) 111 switch (hr->http_status)
112 { 112 {
113 case MHD_HTTP_OK: 113 case MHD_HTTP_OK:
114 GNUNET_assert (NULL != dd->wtid); 114 tts->wtid = dd->wtid;
115 tts->wtid = *dd->wtid;
116 if (NULL != tts->bank_transfer_reference) 115 if (NULL != tts->bank_transfer_reference)
117 { 116 {
118 const struct TALER_TESTING_Command *bank_transfer_cmd; 117 const struct TALER_TESTING_Command *bank_transfer_cmd;
@@ -140,7 +139,7 @@ deposit_wtid_cb (void *cls,
140 } 139 }
141 140
142 /* Compare that expected and gotten subjects match. */ 141 /* Compare that expected and gotten subjects match. */
143 if (0 != GNUNET_memcmp (dd->wtid, 142 if (0 != GNUNET_memcmp (&dd->wtid,
144 wtid_want)) 143 wtid_want))
145 { 144 {
146 GNUNET_break (0); 145 GNUNET_break (0);