diff options
author | Christian Grothoff <christian@grothoff.org> | 2016-06-13 11:40:29 +0000 |
---|---|---|
committer | Christian Grothoff <christian@grothoff.org> | 2016-06-13 11:40:29 +0000 |
commit | 0cf4193a34c4445b99b94c3c315d6a1361835cb6 (patch) | |
tree | 3bd216a81a7e0f33860c68a0905d90d363a37e4a /src/my | |
parent | e290fbfbeae0a3bccf2c2dc68f5d37bc1f3c4f81 (diff) | |
download | gnunet-0cf4193a34c4445b99b94c3c315d6a1361835cb6.tar.gz gnunet-0cf4193a34c4445b99b94c3c315d6a1361835cb6.zip |
fix indentation, bad stack allocation of buf
Diffstat (limited to 'src/my')
-rw-r--r-- | src/my/my.c | 11 | ||||
-rw-r--r-- | src/my/my_query_helper.c | 50 | ||||
-rw-r--r-- | src/my/my_result_helper.c | 187 | ||||
-rw-r--r-- | src/my/test_my.c | 76 |
4 files changed, 147 insertions, 177 deletions
diff --git a/src/my/my.c b/src/my/my.c index 54b1b8e64..5ef2f18cf 100644 --- a/src/my/my.c +++ b/src/my/my.c | |||
@@ -27,7 +27,6 @@ | |||
27 | #include <mysql/mysql.h> | 27 | #include <mysql/mysql.h> |
28 | #include "gnunet_my_lib.h" | 28 | #include "gnunet_my_lib.h" |
29 | 29 | ||
30 | #define STRING_SIZE 50 | ||
31 | 30 | ||
32 | /** | 31 | /** |
33 | * Run a prepared SELECT statement. | 32 | * Run a prepared SELECT statement. |
@@ -94,8 +93,8 @@ GNUNET_MY_exec_prepared (struct GNUNET_MYSQL_Context *mc, | |||
94 | return GNUNET_SYSERR; | 93 | return GNUNET_SYSERR; |
95 | } | 94 | } |
96 | 95 | ||
97 | GNUNET_MY_cleanup_query (params, | 96 | GNUNET_MY_cleanup_query (params, |
98 | qbind); | 97 | qbind); |
99 | } | 98 | } |
100 | 99 | ||
101 | return GNUNET_OK; | 100 | return GNUNET_OK; |
@@ -111,14 +110,14 @@ GNUNET_MY_exec_prepared (struct GNUNET_MYSQL_Context *mc, | |||
111 | */ | 110 | */ |
112 | void | 111 | void |
113 | GNUNET_MY_cleanup_query (struct GNUNET_MY_QueryParam *qp, | 112 | GNUNET_MY_cleanup_query (struct GNUNET_MY_QueryParam *qp, |
114 | MYSQL_BIND * qbind) | 113 | MYSQL_BIND *qbind) |
115 | { | 114 | { |
116 | unsigned int i; | 115 | unsigned int i; |
117 | 116 | ||
118 | for (i=0; NULL != qp[i].conv ;i++) | 117 | for (i=0; NULL != qp[i].conv ;i++) |
119 | if(NULL != qp[i].cleaner) | 118 | if (NULL != qp[i].cleaner) |
120 | qp[i].cleaner (qp[i].conv_cls, | 119 | qp[i].cleaner (qp[i].conv_cls, |
121 | &qbind[i]); | 120 | &qbind[i]); |
122 | } | 121 | } |
123 | 122 | ||
124 | 123 | ||
diff --git a/src/my/my_query_helper.c b/src/my/my_query_helper.c index 8ecfc2b64..c806a73fb 100644 --- a/src/my/my_query_helper.c +++ b/src/my/my_query_helper.c | |||
@@ -37,7 +37,7 @@ | |||
37 | */ | 37 | */ |
38 | static void | 38 | static void |
39 | my_clean_query (void *cls, | 39 | my_clean_query (void *cls, |
40 | MYSQL_BIND *qbind) | 40 | MYSQL_BIND *qbind) |
41 | { | 41 | { |
42 | GNUNET_free (qbind[0].buffer); | 42 | GNUNET_free (qbind[0].buffer); |
43 | } | 43 | } |
@@ -115,21 +115,10 @@ my_conv_uint16 (void *cls, | |||
115 | const struct GNUNET_MY_QueryParam * qp, | 115 | const struct GNUNET_MY_QueryParam * qp, |
116 | MYSQL_BIND *qbind) | 116 | MYSQL_BIND *qbind) |
117 | { | 117 | { |
118 | const uint16_t *u_hbo = qp->data; | ||
119 | uint16_t *u_nbo; | ||
120 | |||
121 | GNUNET_assert (1 == qp->num_params); | 118 | GNUNET_assert (1 == qp->num_params); |
122 | 119 | qbind->buffer = (void *) qp->data; | |
123 | u_nbo = GNUNET_new (uint16_t); | 120 | qbind->buffer_length = sizeof (uint16_t); |
124 | if (NULL == u_nbo) | ||
125 | return -1; | ||
126 | |||
127 | *u_nbo = *u_hbo; | ||
128 | |||
129 | qbind->buffer = (void *) u_nbo; | ||
130 | qbind->buffer_length = sizeof(uint16_t); | ||
131 | qbind->buffer_type = MYSQL_TYPE_SHORT; | 121 | qbind->buffer_type = MYSQL_TYPE_SHORT; |
132 | |||
133 | return 1; | 122 | return 1; |
134 | } | 123 | } |
135 | 124 | ||
@@ -144,7 +133,7 @@ GNUNET_MY_query_param_uint16 (const uint16_t *x) | |||
144 | { | 133 | { |
145 | struct GNUNET_MY_QueryParam res = { | 134 | struct GNUNET_MY_QueryParam res = { |
146 | .conv = &my_conv_uint16, | 135 | .conv = &my_conv_uint16, |
147 | .cleaner = &my_clean_query, | 136 | .cleaner = NULL, |
148 | .conv_cls = NULL, | 137 | .conv_cls = NULL, |
149 | .num_params = 1, | 138 | .num_params = 1, |
150 | .data = x, | 139 | .data = x, |
@@ -168,16 +157,8 @@ my_conv_uint32 (void *cls, | |||
168 | const struct GNUNET_MY_QueryParam *qp, | 157 | const struct GNUNET_MY_QueryParam *qp, |
169 | MYSQL_BIND *qbind) | 158 | MYSQL_BIND *qbind) |
170 | { | 159 | { |
171 | const uint32_t *u_hbo = qp->data; | ||
172 | uint32_t * u_nbo; | ||
173 | |||
174 | GNUNET_assert (1 == qp->num_params); | 160 | GNUNET_assert (1 == qp->num_params); |
175 | 161 | qbind->buffer = (void *) qp->data; | |
176 | u_nbo = GNUNET_new (uint32_t); | ||
177 | |||
178 | *u_nbo = *u_hbo; | ||
179 | |||
180 | qbind->buffer = (void *) u_nbo; | ||
181 | qbind->buffer_length = sizeof(uint32_t); | 162 | qbind->buffer_length = sizeof(uint32_t); |
182 | qbind->buffer_type = MYSQL_TYPE_LONG; | 163 | qbind->buffer_type = MYSQL_TYPE_LONG; |
183 | 164 | ||
@@ -195,7 +176,7 @@ GNUNET_MY_query_param_uint32 (const uint32_t *x) | |||
195 | { | 176 | { |
196 | struct GNUNET_MY_QueryParam res = { | 177 | struct GNUNET_MY_QueryParam res = { |
197 | .conv = &my_conv_uint32, | 178 | .conv = &my_conv_uint32, |
198 | .cleaner = &my_clean_query, | 179 | .cleaner = NULL, |
199 | .conv_cls = NULL, | 180 | .conv_cls = NULL, |
200 | .num_params = 1, | 181 | .num_params = 1, |
201 | .data = x, | 182 | .data = x, |
@@ -216,22 +197,13 @@ GNUNET_MY_query_param_uint32 (const uint32_t *x) | |||
216 | */ | 197 | */ |
217 | static int | 198 | static int |
218 | my_conv_uint64 (void *cls, | 199 | my_conv_uint64 (void *cls, |
219 | const struct GNUNET_MY_QueryParam *qp, | 200 | const struct GNUNET_MY_QueryParam *qp, |
220 | MYSQL_BIND * qbind) | 201 | MYSQL_BIND * qbind) |
221 | { | 202 | { |
222 | const uint64_t * u_hbo = qp->data; | ||
223 | uint64_t *u_nbo; | ||
224 | |||
225 | GNUNET_assert (1 == qp->num_params); | 203 | GNUNET_assert (1 == qp->num_params); |
226 | 204 | qbind->buffer = (void *) qp->data; | |
227 | u_nbo = GNUNET_new(uint64_t); | ||
228 | |||
229 | *u_nbo = *u_hbo; | ||
230 | |||
231 | qbind->buffer = (void *) u_nbo; | ||
232 | qbind->buffer_length = sizeof (uint64_t); | 205 | qbind->buffer_length = sizeof (uint64_t); |
233 | qbind->buffer_type = MYSQL_TYPE_LONGLONG; | 206 | qbind->buffer_type = MYSQL_TYPE_LONGLONG; |
234 | |||
235 | return 1; | 207 | return 1; |
236 | } | 208 | } |
237 | 209 | ||
@@ -246,7 +218,7 @@ GNUNET_MY_query_param_uint64 (const uint64_t *x) | |||
246 | { | 218 | { |
247 | struct GNUNET_MY_QueryParam res = { | 219 | struct GNUNET_MY_QueryParam res = { |
248 | .conv = &my_conv_uint64, | 220 | .conv = &my_conv_uint64, |
249 | .cleaner = &my_clean_query, | 221 | .cleaner = NULL, |
250 | .conv_cls = NULL, | 222 | .conv_cls = NULL, |
251 | .num_params = 1, | 223 | .num_params = 1, |
252 | .data = x, | 224 | .data = x, |
@@ -387,4 +359,4 @@ GNUNET_MY_query_param_absolute_time_nbo (const struct GNUNET_TIME_AbsoluteNBO *x | |||
387 | } | 359 | } |
388 | 360 | ||
389 | 361 | ||
390 | /* end of my_query_helper.c */ \ No newline at end of file | 362 | /* end of my_query_helper.c */ |
diff --git a/src/my/my_result_helper.c b/src/my/my_result_helper.c index c0a1dff4d..a91a24d90 100644 --- a/src/my/my_result_helper.c +++ b/src/my/my_result_helper.c | |||
@@ -116,7 +116,7 @@ cleanup_varsize_blob (void *cls, | |||
116 | if (NULL != *ptr) | 116 | if (NULL != *ptr) |
117 | { | 117 | { |
118 | GNUNET_free (*ptr); | 118 | GNUNET_free (*ptr); |
119 | *ptr = NULL; | 119 | *ptr = NULL; |
120 | } | 120 | } |
121 | } | 121 | } |
122 | 122 | ||
@@ -297,7 +297,7 @@ post_extract_rsa_public_key (void *cls, | |||
297 | GNUNET_free (buf); | 297 | GNUNET_free (buf); |
298 | return GNUNET_SYSERR; | 298 | return GNUNET_SYSERR; |
299 | } | 299 | } |
300 | 300 | ||
301 | *pk = GNUNET_CRYPTO_rsa_public_key_decode (buf, | 301 | *pk = GNUNET_CRYPTO_rsa_public_key_decode (buf, |
302 | size); | 302 | size); |
303 | GNUNET_free (buf); | 303 | GNUNET_free (buf); |
@@ -398,10 +398,10 @@ pre_extract_rsa_signature (void *cls, | |||
398 | */ | 398 | */ |
399 | static int | 399 | static int |
400 | post_extract_rsa_signature (void *cls, | 400 | post_extract_rsa_signature (void *cls, |
401 | struct GNUNET_MY_ResultSpec *rs, | 401 | struct GNUNET_MY_ResultSpec *rs, |
402 | MYSQL_STMT *stmt, | 402 | MYSQL_STMT *stmt, |
403 | unsigned int column, | 403 | unsigned int column, |
404 | MYSQL_BIND *results) | 404 | MYSQL_BIND *results) |
405 | { | 405 | { |
406 | struct GNUNET_CRYPTO_RsaSignature **sig = rs->dst; | 406 | struct GNUNET_CRYPTO_RsaSignature **sig = rs->dst; |
407 | void *buf; | 407 | void *buf; |
@@ -483,23 +483,23 @@ GNUNET_MY_result_spec_rsa_signature (struct GNUNET_CRYPTO_RsaSignature **sig) | |||
483 | 483 | ||
484 | 484 | ||
485 | /** | 485 | /** |
486 | * Extract data from a Mysql database @a result at row @a row | 486 | * Extract data from a Mysql database @a result at row @a row |
487 | * | 487 | * |
488 | * @param cls closure | 488 | * @param cls closure |
489 | * @param[in,out] rs | 489 | * @param[in,out] rs |
490 | * @param stmt the mysql statement that is being run | 490 | * @param stmt the mysql statement that is being run |
491 | * @param column the column that is being processed | 491 | * @param column the column that is being processed |
492 | * @param[out] results | 492 | * @param[out] results |
493 | * @return | 493 | * @return |
494 | * #GNUNET_OK if all results could be extracted | 494 | * #GNUNET_OK if all results could be extracted |
495 | * #GNUNET_SYSERR if a result was invalid (non existing field or NULL) | 495 | * #GNUNET_SYSERR if a result was invalid (non existing field or NULL) |
496 | */ | 496 | */ |
497 | static int | 497 | static int |
498 | pre_extract_string (void * cls, | 498 | pre_extract_string (void * cls, |
499 | struct GNUNET_MY_ResultSpec *rs, | 499 | struct GNUNET_MY_ResultSpec *rs, |
500 | MYSQL_STMT *stmt, | 500 | MYSQL_STMT *stmt, |
501 | unsigned int column, | 501 | unsigned int column, |
502 | MYSQL_BIND *results) | 502 | MYSQL_BIND *results) |
503 | { | 503 | { |
504 | results[0].buffer = NULL; | 504 | results[0].buffer = NULL; |
505 | results[0].buffer_length = 0; | 505 | results[0].buffer_length = 0; |
@@ -511,32 +511,31 @@ pre_extract_string (void * cls, | |||
511 | 511 | ||
512 | 512 | ||
513 | /** | 513 | /** |
514 | * Check size of extracted fixed size data from a Mysql database @a | 514 | * Check size of extracted fixed size data from a Mysql database @a |
515 | * | 515 | * |
516 | * @param cls closure | 516 | * @param cls closure |
517 | * @param[in,out] rs | 517 | * @param[in,out] rs |
518 | * @param stmt the mysql statement that is being run | 518 | * @param stmt the mysql statement that is being run |
519 | * @param column the column that is being processed | 519 | * @param column the column that is being processed |
520 | * @param[out] results | 520 | * @param[out] results |
521 | * @return | 521 | * @return |
522 | * #GNUNET_OK if all results could be extracted | 522 | * #GNUNET_OK if all results could be extracted |
523 | * #GNUNET_SYSERR if a result was invalid (non existing field or NULL) | 523 | * #GNUNET_SYSERR if a result was invalid (non existing field or NULL) |
524 | */ | 524 | */ |
525 | static int | 525 | static int |
526 | post_extract_string (void * cls, | 526 | post_extract_string (void * cls, |
527 | struct GNUNET_MY_ResultSpec *rs, | 527 | struct GNUNET_MY_ResultSpec *rs, |
528 | MYSQL_STMT *stmt, | 528 | MYSQL_STMT *stmt, |
529 | unsigned int column, | 529 | unsigned int column, |
530 | MYSQL_BIND *results) | 530 | MYSQL_BIND *results) |
531 | { | 531 | { |
532 | size_t size; | 532 | size_t size = (size_t) rs->mysql_bind_output_length; |
533 | 533 | char *buf; | |
534 | size = (size_t) rs->mysql_bind_output_length; | ||
535 | char buf[size]; | ||
536 | 534 | ||
537 | if (rs->mysql_bind_output_length != size) | 535 | if (rs->mysql_bind_output_length != size) |
538 | return GNUNET_SYSERR; | 536 | return GNUNET_SYSERR; |
539 | 537 | ||
538 | buf = GNUNET_malloc (size); | ||
540 | results[0].buffer = buf; | 539 | results[0].buffer = buf; |
541 | results[0].buffer_length = size; | 540 | results[0].buffer_length = size; |
542 | results[0].buffer_type = MYSQL_TYPE_BLOB; | 541 | results[0].buffer_type = MYSQL_TYPE_BLOB; |
@@ -550,9 +549,7 @@ post_extract_string (void * cls, | |||
550 | GNUNET_free (buf); | 549 | GNUNET_free (buf); |
551 | return GNUNET_SYSERR; | 550 | return GNUNET_SYSERR; |
552 | } | 551 | } |
553 | |||
554 | rs->dst = buf; | 552 | rs->dst = buf; |
555 | |||
556 | return GNUNET_OK; | 553 | return GNUNET_OK; |
557 | } | 554 | } |
558 | 555 | ||
@@ -621,12 +618,12 @@ GNUNET_MY_result_spec_absolute_time_nbo (struct GNUNET_TIME_AbsoluteNBO *at) | |||
621 | */ | 618 | */ |
622 | static int | 619 | static int |
623 | pre_extract_uint16 (void *cls, | 620 | pre_extract_uint16 (void *cls, |
624 | struct GNUNET_MY_ResultSpec *rs, | 621 | struct GNUNET_MY_ResultSpec *rs, |
625 | MYSQL_STMT *stmt, | 622 | MYSQL_STMT *stmt, |
626 | unsigned int column, | 623 | unsigned int column, |
627 | MYSQL_BIND *results) | 624 | MYSQL_BIND *results) |
628 | { | 625 | { |
629 | results[0].buffer = (char *)rs->dst; | 626 | results[0].buffer = rs->dst; |
630 | results[0].buffer_length = rs->dst_size; | 627 | results[0].buffer_length = rs->dst_size; |
631 | results[0].length = &rs->mysql_bind_output_length; | 628 | results[0].length = &rs->mysql_bind_output_length; |
632 | results[0].buffer_type = MYSQL_TYPE_SHORT; | 629 | results[0].buffer_type = MYSQL_TYPE_SHORT; |
@@ -649,10 +646,10 @@ pre_extract_uint16 (void *cls, | |||
649 | */ | 646 | */ |
650 | static int | 647 | static int |
651 | post_extract_uint16 (void *cls, | 648 | post_extract_uint16 (void *cls, |
652 | struct GNUNET_MY_ResultSpec *rs, | 649 | struct GNUNET_MY_ResultSpec *rs, |
653 | MYSQL_STMT *stmt, | 650 | MYSQL_STMT *stmt, |
654 | unsigned int column, | 651 | unsigned int column, |
655 | MYSQL_BIND *results) | 652 | MYSQL_BIND *results) |
656 | { | 653 | { |
657 | if (rs->dst_size != rs->mysql_bind_output_length) | 654 | if (rs->dst_size != rs->mysql_bind_output_length) |
658 | return GNUNET_SYSERR; | 655 | return GNUNET_SYSERR; |
@@ -696,12 +693,12 @@ GNUNET_MY_result_spec_uint16 (uint16_t *u16) | |||
696 | */ | 693 | */ |
697 | static int | 694 | static int |
698 | pre_extract_uint32 (void *cls, | 695 | pre_extract_uint32 (void *cls, |
699 | struct GNUNET_MY_ResultSpec *rs, | 696 | struct GNUNET_MY_ResultSpec *rs, |
700 | MYSQL_STMT *stmt, | 697 | MYSQL_STMT *stmt, |
701 | unsigned int column, | 698 | unsigned int column, |
702 | MYSQL_BIND *results) | 699 | MYSQL_BIND *results) |
703 | { | 700 | { |
704 | results[0].buffer = (int *)rs->dst; | 701 | results[0].buffer = rs->dst; |
705 | results[0].buffer_length = rs->dst_size; | 702 | results[0].buffer_length = rs->dst_size; |
706 | results[0].length = &rs->mysql_bind_output_length; | 703 | results[0].length = &rs->mysql_bind_output_length; |
707 | results[0].buffer_type = MYSQL_TYPE_LONG; | 704 | results[0].buffer_type = MYSQL_TYPE_LONG; |
@@ -725,10 +722,10 @@ pre_extract_uint32 (void *cls, | |||
725 | */ | 722 | */ |
726 | static int | 723 | static int |
727 | post_extract_uint32 (void *cls, | 724 | post_extract_uint32 (void *cls, |
728 | struct GNUNET_MY_ResultSpec *rs, | 725 | struct GNUNET_MY_ResultSpec *rs, |
729 | MYSQL_STMT * stmt, | 726 | MYSQL_STMT * stmt, |
730 | unsigned int column, | 727 | unsigned int column, |
731 | MYSQL_BIND *results) | 728 | MYSQL_BIND *results) |
732 | { | 729 | { |
733 | if (rs->dst_size != rs->mysql_bind_output_length) | 730 | if (rs->dst_size != rs->mysql_bind_output_length) |
734 | return GNUNET_SYSERR; | 731 | return GNUNET_SYSERR; |
@@ -758,23 +755,23 @@ GNUNET_MY_result_spec_uint32 (uint32_t *u32) | |||
758 | 755 | ||
759 | 756 | ||
760 | /** | 757 | /** |
761 | * Extract data from a MYSQL database @a result at row @a row | 758 | * Extract data from a MYSQL database @a result at row @a row |
762 | * | 759 | * |
763 | * @param cls closure | 760 | * @param cls closure |
764 | * @param[in,out] rs | 761 | * @param[in,out] rs |
765 | * @param stmt the mysql statement that is being run | 762 | * @param stmt the mysql statement that is being run |
766 | * @param column the column that is being processed | 763 | * @param column the column that is being processed |
767 | * @param[out] results | 764 | * @param[out] results |
768 | * @return | 765 | * @return |
769 | * #GNUNET_OK if all results could be extracted | 766 | * #GNUNET_OK if all results could be extracted |
770 | * #GNUNET_SYSERR if a result was invalid (non-existing field or NULL) | 767 | * #GNUNET_SYSERR if a result was invalid (non-existing field or NULL) |
771 | */ | 768 | */ |
772 | static int | 769 | static int |
773 | pre_extract_uint64 (void *cls, | 770 | pre_extract_uint64 (void *cls, |
774 | struct GNUNET_MY_ResultSpec *rs, | 771 | struct GNUNET_MY_ResultSpec *rs, |
775 | MYSQL_STMT *stmt, | 772 | MYSQL_STMT *stmt, |
776 | unsigned int column, | 773 | unsigned int column, |
777 | MYSQL_BIND *results) | 774 | MYSQL_BIND *results) |
778 | { | 775 | { |
779 | results[0].buffer = rs->dst; | 776 | results[0].buffer = rs->dst; |
780 | results[0].buffer_length = rs->dst_size; | 777 | results[0].buffer_length = rs->dst_size; |
@@ -786,23 +783,23 @@ pre_extract_uint64 (void *cls, | |||
786 | 783 | ||
787 | 784 | ||
788 | /** | 785 | /** |
789 | * Check size of extracted fixe size data from a Mysql database | 786 | * Check size of extracted fixe size data from a Mysql database |
790 | * | 787 | * |
791 | * @param cls closure | 788 | * @param cls closure |
792 | * @param[in,out] rs | 789 | * @param[in,out] rs |
793 | * @param stmt the mysql statement that is being run | 790 | * @param stmt the mysql statement that is being run |
794 | * @param column the column that is being processed | 791 | * @param column the column that is being processed |
795 | * @param[out] results | 792 | * @param[out] results |
796 | * @return | 793 | * @return |
797 | * #GNUNET_OK if all results could be extracted | 794 | * #GNUNET_OK if all results could be extracted |
798 | * #GNUNET_SYSERR if a result was invalid (non-existing field or NULL) | 795 | * #GNUNET_SYSERR if a result was invalid (non-existing field or NULL) |
799 | */ | 796 | */ |
800 | static int | 797 | static int |
801 | post_extract_uint64 (void *cls, | 798 | post_extract_uint64 (void *cls, |
802 | struct GNUNET_MY_ResultSpec *rs, | 799 | struct GNUNET_MY_ResultSpec *rs, |
803 | MYSQL_STMT *stmt, | 800 | MYSQL_STMT *stmt, |
804 | unsigned int column, | 801 | unsigned int column, |
805 | MYSQL_BIND *results) | 802 | MYSQL_BIND *results) |
806 | { | 803 | { |
807 | if (rs->dst_size != rs->mysql_bind_output_length) | 804 | if (rs->dst_size != rs->mysql_bind_output_length) |
808 | return GNUNET_SYSERR; | 805 | return GNUNET_SYSERR; |
@@ -811,11 +808,11 @@ post_extract_uint64 (void *cls, | |||
811 | 808 | ||
812 | 809 | ||
813 | /** | 810 | /** |
814 | * uint64_t expected. | 811 | * uint64_t expected. |
815 | * | 812 | * |
816 | * @param[out] u64 where to store the result | 813 | * @param[out] u64 where to store the result |
817 | * @return array entry for the result specification to use | 814 | * @return array entry for the result specification to use |
818 | */ | 815 | */ |
819 | struct GNUNET_MY_ResultSpec | 816 | struct GNUNET_MY_ResultSpec |
820 | GNUNET_MY_result_spec_uint64 (uint64_t *u64) | 817 | GNUNET_MY_result_spec_uint64 (uint64_t *u64) |
821 | { | 818 | { |
diff --git a/src/my/test_my.c b/src/my/test_my.c index 3e051e467..4bea101ca 100644 --- a/src/my/test_my.c +++ b/src/my/test_my.c | |||
@@ -75,29 +75,30 @@ run_queries (struct GNUNET_MYSQL_Context *context) | |||
75 | pub = GNUNET_CRYPTO_rsa_private_key_get_public (priv); | 75 | pub = GNUNET_CRYPTO_rsa_private_key_get_public (priv); |
76 | memset (&hmsg, 42, sizeof(hmsg)); | 76 | memset (&hmsg, 42, sizeof(hmsg)); |
77 | sig = GNUNET_CRYPTO_rsa_sign_fdh (priv, | 77 | sig = GNUNET_CRYPTO_rsa_sign_fdh (priv, |
78 | &hmsg); | 78 | &hmsg); |
79 | u16 = 16; | 79 | u16 = 16; |
80 | u32 = 32; | 80 | u32 = 32; |
81 | u64 = 64; | 81 | u64 = UINT64_MAX; |
82 | 82 | ||
83 | memset (&hc, 0, sizeof(hc)); | 83 | memset (&hc, 0, sizeof(hc)); |
84 | memset (&hc2, 0, sizeof(hc2)); | 84 | memset (&hc2, 0, sizeof(hc2)); |
85 | 85 | ||
86 | statements_handle_insert = GNUNET_MYSQL_statement_prepare (context, | 86 | statements_handle_insert |
87 | "INSERT INTO test_my2 (" | 87 | = GNUNET_MYSQL_statement_prepare (context, |
88 | " pub" | 88 | "INSERT INTO test_my2 (" |
89 | ",sig" | 89 | " pub" |
90 | ",abs_time" | 90 | ",sig" |
91 | ",forever" | 91 | ",abs_time" |
92 | ",abs_time_nbo" | 92 | ",forever" |
93 | ",hash" | 93 | ",abs_time_nbo" |
94 | ",vsize" | 94 | ",hash" |
95 | ",str" | 95 | ",vsize" |
96 | ",u16" | 96 | ",str" |
97 | ",u32" | 97 | ",u16" |
98 | ",u64" | 98 | ",u32" |
99 | ") VALUES " | 99 | ",u64" |
100 | "( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"); | 100 | ") VALUES " |
101 | "( ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"); | ||
101 | 102 | ||
102 | if (NULL == statements_handle_insert) | 103 | if (NULL == statements_handle_insert) |
103 | { | 104 | { |
@@ -128,19 +129,20 @@ run_queries (struct GNUNET_MYSQL_Context *context) | |||
128 | return 1; | 129 | return 1; |
129 | } | 130 | } |
130 | 131 | ||
131 | statements_handle_select = GNUNET_MYSQL_statement_prepare (context, | 132 | statements_handle_select |
132 | "SELECT" | 133 | = GNUNET_MYSQL_statement_prepare (context, |
133 | " pub" | 134 | "SELECT" |
134 | ",sig" | 135 | " pub" |
135 | ",abs_time" | 136 | ",sig" |
136 | ",forever" | 137 | ",abs_time" |
137 | ",hash" | 138 | ",forever" |
138 | ",vsize" | 139 | ",hash" |
139 | ",str" | 140 | ",vsize" |
140 | ",u16" | 141 | ",str" |
141 | ",u32" | 142 | ",u16" |
142 | ",u64" | 143 | ",u32" |
143 | " FROM test_my2"); | 144 | ",u64" |
145 | " FROM test_my2"); | ||
144 | 146 | ||
145 | if (NULL == statements_handle_select) | 147 | if (NULL == statements_handle_select) |
146 | { | 148 | { |
@@ -200,21 +202,21 @@ run_queries (struct GNUNET_MYSQL_Context *context) | |||
200 | msg2, | 202 | msg2, |
201 | msg2_len)); | 203 | msg2_len)); |
202 | 204 | ||
203 | GNUNET_break (strlen (msg3) == strlen(msg4)); | 205 | GNUNET_break (strlen (msg3) == strlen(msg4)); |
204 | GNUNET_break (0 == | 206 | GNUNET_break (0 == |
205 | strcmp (msg3, | 207 | strcmp (msg3, |
206 | msg4)); | 208 | msg4)); |
207 | 209 | ||
208 | GNUNET_break (16 == u162); | 210 | GNUNET_break (16 == u162); |
209 | GNUNET_break (32 == u322); | 211 | GNUNET_break (32 == u322); |
210 | GNUNET_break (64 == u642); | 212 | GNUNET_break (UINT64_MAX == u642); |
211 | 213 | ||
212 | GNUNET_MY_cleanup_result (results_select); | 214 | GNUNET_MY_cleanup_result (results_select); |
213 | 215 | ||
214 | GNUNET_CRYPTO_rsa_signature_free (sig); | 216 | GNUNET_CRYPTO_rsa_signature_free (sig); |
215 | GNUNET_CRYPTO_rsa_private_key_free (priv); | 217 | GNUNET_CRYPTO_rsa_private_key_free (priv); |
216 | GNUNET_CRYPTO_rsa_public_key_free (pub); | 218 | GNUNET_CRYPTO_rsa_public_key_free (pub); |
217 | 219 | ||
218 | if (GNUNET_OK != ret) | 220 | if (GNUNET_OK != ret) |
219 | return 1; | 221 | return 1; |
220 | 222 | ||
@@ -225,8 +227,8 @@ GNUNET_break (0 == | |||
225 | int | 227 | int |
226 | main (int argc, const char * const argv[]) | 228 | main (int argc, const char * const argv[]) |
227 | { | 229 | { |
228 | struct GNUNET_CONFIGURATION_Handle *config = NULL; | 230 | struct GNUNET_CONFIGURATION_Handle *config; |
229 | struct GNUNET_MYSQL_Context *context = NULL; | 231 | struct GNUNET_MYSQL_Context *context; |
230 | int ret; | 232 | int ret; |
231 | 233 | ||
232 | GNUNET_log_setup ("test-my", | 234 | GNUNET_log_setup ("test-my", |