diff options
author | Martin Schanzenbach <schanzen@gnunet.org> | 2022-11-05 22:44:46 +0900 |
---|---|---|
committer | Martin Schanzenbach <schanzen@gnunet.org> | 2022-11-05 22:44:46 +0900 |
commit | 4db7f94ce6c8d6aed2b834c050b983de42f98718 (patch) | |
tree | 6e043aec9f0e12601d986506669fb8d957a17d0f /src/reclaim | |
parent | d68327a9085cbc9b871fa92d23a09d1cb2b6f6b0 (diff) | |
download | gnunet-4db7f94ce6c8d6aed2b834c050b983de42f98718.tar.gz gnunet-4db7f94ce6c8d6aed2b834c050b983de42f98718.zip |
-fix hton length mismatch
Diffstat (limited to 'src/reclaim')
-rw-r--r-- | src/reclaim/reclaim_attribute.c | 12 | ||||
-rw-r--r-- | src/reclaim/reclaim_credential.c | 20 |
2 files changed, 16 insertions, 16 deletions
diff --git a/src/reclaim/reclaim_attribute.c b/src/reclaim/reclaim_attribute.c index b5c41b2d1..c107355f7 100644 --- a/src/reclaim/reclaim_attribute.c +++ b/src/reclaim/reclaim_attribute.c | |||
@@ -472,12 +472,12 @@ GNUNET_RECLAIM_attribute_serialize ( | |||
472 | char *write_ptr; | 472 | char *write_ptr; |
473 | 473 | ||
474 | attr_ser = (struct Attribute *) result; | 474 | attr_ser = (struct Attribute *) result; |
475 | attr_ser->attribute_type = htons (attr->type); | 475 | attr_ser->attribute_type = htonl (attr->type); |
476 | attr_ser->attribute_flag = htonl (attr->flag); | 476 | attr_ser->attribute_flag = htonl (attr->flag); |
477 | attr_ser->attribute_id = attr->id; | 477 | attr_ser->attribute_id = attr->id; |
478 | attr_ser->credential_id = attr->credential; | 478 | attr_ser->credential_id = attr->credential; |
479 | name_len = strlen (attr->name); | 479 | name_len = strlen (attr->name); |
480 | attr_ser->name_len = htons (name_len); | 480 | attr_ser->name_len = htonl (name_len); |
481 | write_ptr = (char *) &attr_ser[1]; | 481 | write_ptr = (char *) &attr_ser[1]; |
482 | GNUNET_memcpy (write_ptr, attr->name, name_len); | 482 | GNUNET_memcpy (write_ptr, attr->name, name_len); |
483 | write_ptr += name_len; | 483 | write_ptr += name_len; |
@@ -486,7 +486,7 @@ GNUNET_RECLAIM_attribute_serialize ( | |||
486 | // &attr_ser[1]); | 486 | // &attr_ser[1]); |
487 | data_len_ser = attr->data_size; | 487 | data_len_ser = attr->data_size; |
488 | GNUNET_memcpy (write_ptr, attr->data, attr->data_size); | 488 | GNUNET_memcpy (write_ptr, attr->data, attr->data_size); |
489 | attr_ser->data_size = htons (data_len_ser); | 489 | attr_ser->data_size = htonl (data_len_ser); |
490 | 490 | ||
491 | return sizeof(struct Attribute) + strlen (attr->name) + attr->data_size; | 491 | return sizeof(struct Attribute) + strlen (attr->name) + attr->data_size; |
492 | } | 492 | } |
@@ -514,8 +514,8 @@ GNUNET_RECLAIM_attribute_deserialize (const char *data, size_t data_size, | |||
514 | return -1; | 514 | return -1; |
515 | 515 | ||
516 | attr_ser = (struct Attribute *) data; | 516 | attr_ser = (struct Attribute *) data; |
517 | data_len = ntohs (attr_ser->data_size); | 517 | data_len = ntohl (attr_ser->data_size); |
518 | name_len = ntohs (attr_ser->name_len); | 518 | name_len = ntohl (attr_ser->name_len); |
519 | if (data_size < sizeof(struct Attribute) + data_len + name_len) | 519 | if (data_size < sizeof(struct Attribute) + data_len + name_len) |
520 | { | 520 | { |
521 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 521 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
@@ -524,7 +524,7 @@ GNUNET_RECLAIM_attribute_deserialize (const char *data, size_t data_size, | |||
524 | } | 524 | } |
525 | attribute = GNUNET_malloc (sizeof(struct GNUNET_RECLAIM_Attribute) | 525 | attribute = GNUNET_malloc (sizeof(struct GNUNET_RECLAIM_Attribute) |
526 | + data_len + name_len + 1); | 526 | + data_len + name_len + 1); |
527 | attribute->type = ntohs (attr_ser->attribute_type); | 527 | attribute->type = ntohl (attr_ser->attribute_type); |
528 | attribute->flag = ntohl (attr_ser->attribute_flag); | 528 | attribute->flag = ntohl (attr_ser->attribute_flag); |
529 | attribute->id = attr_ser->attribute_id; | 529 | attribute->id = attr_ser->attribute_id; |
530 | attribute->credential = attr_ser->credential_id; | 530 | attribute->credential = attr_ser->credential_id; |
diff --git a/src/reclaim/reclaim_credential.c b/src/reclaim/reclaim_credential.c index 6dc1a1fcf..c7eefc916 100644 --- a/src/reclaim/reclaim_credential.c +++ b/src/reclaim/reclaim_credential.c | |||
@@ -437,11 +437,11 @@ GNUNET_RECLAIM_credential_serialize ( | |||
437 | char *write_ptr; | 437 | char *write_ptr; |
438 | 438 | ||
439 | atts = (struct Credential *) result; | 439 | atts = (struct Credential *) result; |
440 | atts->credential_type = htons (credential->type); | 440 | atts->credential_type = htonl (credential->type); |
441 | atts->credential_flag = htonl (credential->flag); | 441 | atts->credential_flag = htonl (credential->flag); |
442 | atts->credential_id = credential->id; | 442 | atts->credential_id = credential->id; |
443 | name_len = strlen (credential->name); | 443 | name_len = strlen (credential->name); |
444 | atts->name_len = htons (name_len); | 444 | atts->name_len = htonl (name_len); |
445 | write_ptr = (char *) &atts[1]; | 445 | write_ptr = (char *) &atts[1]; |
446 | GNUNET_memcpy (write_ptr, credential->name, name_len); | 446 | GNUNET_memcpy (write_ptr, credential->name, name_len); |
447 | write_ptr += name_len; | 447 | write_ptr += name_len; |
@@ -450,7 +450,7 @@ GNUNET_RECLAIM_credential_serialize ( | |||
450 | // &attr_ser[1]); | 450 | // &attr_ser[1]); |
451 | data_len_ser = credential->data_size; | 451 | data_len_ser = credential->data_size; |
452 | GNUNET_memcpy (write_ptr, credential->data, credential->data_size); | 452 | GNUNET_memcpy (write_ptr, credential->data, credential->data_size); |
453 | atts->data_size = htons (data_len_ser); | 453 | atts->data_size = htonl (data_len_ser); |
454 | 454 | ||
455 | return sizeof(struct Credential) + strlen (credential->name) | 455 | return sizeof(struct Credential) + strlen (credential->name) |
456 | + credential->data_size; | 456 | + credential->data_size; |
@@ -478,8 +478,8 @@ GNUNET_RECLAIM_credential_deserialize (const char *data, size_t data_size) | |||
478 | return NULL; | 478 | return NULL; |
479 | 479 | ||
480 | atts = (struct Credential *) data; | 480 | atts = (struct Credential *) data; |
481 | data_len = ntohs (atts->data_size); | 481 | data_len = ntohl (atts->data_size); |
482 | name_len = ntohs (atts->name_len); | 482 | name_len = ntohl (atts->name_len); |
483 | if (data_size < sizeof(struct Credential) + data_len + name_len) | 483 | if (data_size < sizeof(struct Credential) + data_len + name_len) |
484 | { | 484 | { |
485 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 485 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
@@ -488,7 +488,7 @@ GNUNET_RECLAIM_credential_deserialize (const char *data, size_t data_size) | |||
488 | } | 488 | } |
489 | credential = GNUNET_malloc (sizeof(struct GNUNET_RECLAIM_Credential) | 489 | credential = GNUNET_malloc (sizeof(struct GNUNET_RECLAIM_Credential) |
490 | + data_len + name_len + 1); | 490 | + data_len + name_len + 1); |
491 | credential->type = ntohs (atts->credential_type); | 491 | credential->type = ntohl (atts->credential_type); |
492 | credential->flag = ntohl (atts->credential_flag); | 492 | credential->flag = ntohl (atts->credential_flag); |
493 | credential->id = atts->credential_id; | 493 | credential->id = atts->credential_id; |
494 | credential->data_size = data_len; | 494 | credential->data_size = data_len; |
@@ -856,11 +856,11 @@ GNUNET_RECLAIM_presentation_serialize ( | |||
856 | char *write_ptr; | 856 | char *write_ptr; |
857 | 857 | ||
858 | atts = (struct Presentation *) result; | 858 | atts = (struct Presentation *) result; |
859 | atts->presentation_type = htons (presentation->type); | 859 | atts->presentation_type = htonl (presentation->type); |
860 | atts->credential_id = presentation->credential_id; | 860 | atts->credential_id = presentation->credential_id; |
861 | write_ptr = (char *) &atts[1]; | 861 | write_ptr = (char *) &atts[1]; |
862 | GNUNET_memcpy (write_ptr, presentation->data, presentation->data_size); | 862 | GNUNET_memcpy (write_ptr, presentation->data, presentation->data_size); |
863 | atts->data_size = htons (presentation->data_size); | 863 | atts->data_size = htonl (presentation->data_size); |
864 | 864 | ||
865 | return sizeof(struct Presentation) + presentation->data_size; | 865 | return sizeof(struct Presentation) + presentation->data_size; |
866 | } | 866 | } |
@@ -886,7 +886,7 @@ GNUNET_RECLAIM_presentation_deserialize (const char *data, size_t data_size) | |||
886 | return NULL; | 886 | return NULL; |
887 | 887 | ||
888 | atts = (struct Presentation *) data; | 888 | atts = (struct Presentation *) data; |
889 | data_len = ntohs (atts->data_size); | 889 | data_len = ntohl (atts->data_size); |
890 | if (data_size < sizeof(struct Presentation) + data_len) | 890 | if (data_size < sizeof(struct Presentation) + data_len) |
891 | { | 891 | { |
892 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | 892 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, |
@@ -895,7 +895,7 @@ GNUNET_RECLAIM_presentation_deserialize (const char *data, size_t data_size) | |||
895 | } | 895 | } |
896 | presentation = GNUNET_malloc (sizeof(struct GNUNET_RECLAIM_Presentation) | 896 | presentation = GNUNET_malloc (sizeof(struct GNUNET_RECLAIM_Presentation) |
897 | + data_len); | 897 | + data_len); |
898 | presentation->type = ntohs (atts->presentation_type); | 898 | presentation->type = ntohl (atts->presentation_type); |
899 | presentation->credential_id = atts->credential_id; | 899 | presentation->credential_id = atts->credential_id; |
900 | presentation->data_size = data_len; | 900 | presentation->data_size = data_len; |
901 | 901 | ||