diff options
author | Martin Schanzenbach <schanzen@gnunet.org> | 2022-11-06 22:38:13 +0900 |
---|---|---|
committer | Martin Schanzenbach <schanzen@gnunet.org> | 2022-11-06 22:38:13 +0900 |
commit | a117a9eb8926dd5b566bcf8a5c605939490f851f (patch) | |
tree | a2c967b3c27dfab4501314d13c614ce1ac8da267 /src/reclaim | |
parent | bc3d776dd38651fae221a06a198d427d28693673 (diff) | |
download | gnunet-a117a9eb8926dd5b566bcf8a5c605939490f851f.tar.gz gnunet-a117a9eb8926dd5b566bcf8a5c605939490f851f.zip |
-more size
Diffstat (limited to 'src/reclaim')
-rw-r--r-- | src/reclaim/reclaim_attribute.c | 8 | ||||
-rw-r--r-- | src/reclaim/reclaim_attribute.h | 14 | ||||
-rw-r--r-- | src/reclaim/reclaim_credential.c | 12 | ||||
-rw-r--r-- | src/reclaim/reclaim_credential.h | 14 |
4 files changed, 34 insertions, 14 deletions
diff --git a/src/reclaim/reclaim_attribute.c b/src/reclaim/reclaim_attribute.c index c107355f7..b235ed945 100644 --- a/src/reclaim/reclaim_attribute.c +++ b/src/reclaim/reclaim_attribute.c | |||
@@ -477,7 +477,7 @@ GNUNET_RECLAIM_attribute_serialize ( | |||
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 = htonl (name_len); | 480 | attr_ser->name_len = htons (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 = htonl (data_len_ser); | 489 | attr_ser->data_size = htons (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 = ntohl (attr_ser->data_size); | 517 | data_len = ntohs (attr_ser->data_size); |
518 | name_len = ntohl (attr_ser->name_len); | 518 | name_len = ntohs (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, |
diff --git a/src/reclaim/reclaim_attribute.h b/src/reclaim/reclaim_attribute.h index 285d75d83..44d85e61c 100644 --- a/src/reclaim/reclaim_attribute.h +++ b/src/reclaim/reclaim_attribute.h | |||
@@ -56,14 +56,24 @@ struct Attribute | |||
56 | struct GNUNET_RECLAIM_Identifier credential_id; | 56 | struct GNUNET_RECLAIM_Identifier credential_id; |
57 | 57 | ||
58 | /** | 58 | /** |
59 | * Reserved (alignment) | ||
60 | */ | ||
61 | uint16_t reserved_nl GNUNET_PACKED; | ||
62 | |||
63 | /** | ||
59 | * Name length | 64 | * Name length |
60 | */ | 65 | */ |
61 | uint32_t name_len GNUNET_PACKED; | 66 | uint16_t name_len GNUNET_PACKED; |
67 | |||
68 | /** | ||
69 | * Reserved (alignment) | ||
70 | */ | ||
71 | uint16_t reserved_ds GNUNET_PACKED; | ||
62 | 72 | ||
63 | /** | 73 | /** |
64 | * Data size | 74 | * Data size |
65 | */ | 75 | */ |
66 | uint32_t data_size GNUNET_PACKED; | 76 | uint16_t data_size GNUNET_PACKED; |
67 | 77 | ||
68 | // followed by data_size Attribute value data | 78 | // followed by data_size Attribute value data |
69 | }; | 79 | }; |
diff --git a/src/reclaim/reclaim_credential.c b/src/reclaim/reclaim_credential.c index c7eefc916..1aad261a1 100644 --- a/src/reclaim/reclaim_credential.c +++ b/src/reclaim/reclaim_credential.c | |||
@@ -441,7 +441,7 @@ GNUNET_RECLAIM_credential_serialize ( | |||
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 = htonl (name_len); | 444 | atts->name_len = htons (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 = htonl (data_len_ser); | 453 | atts->data_size = htons (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 = ntohl (atts->data_size); | 481 | data_len = ntohs (atts->data_size); |
482 | name_len = ntohl (atts->name_len); | 482 | name_len = ntohs (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, |
@@ -860,7 +860,7 @@ GNUNET_RECLAIM_presentation_serialize ( | |||
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 = htonl (presentation->data_size); | 863 | atts->data_size = htons (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 = ntohl (atts->data_size); | 889 | data_len = ntohs (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, |
diff --git a/src/reclaim/reclaim_credential.h b/src/reclaim/reclaim_credential.h index 7704ed968..ba91ab8f8 100644 --- a/src/reclaim/reclaim_credential.h +++ b/src/reclaim/reclaim_credential.h | |||
@@ -83,14 +83,24 @@ struct Presentation | |||
83 | struct GNUNET_RECLAIM_Identifier credential_id; | 83 | struct GNUNET_RECLAIM_Identifier credential_id; |
84 | 84 | ||
85 | /** | 85 | /** |
86 | * Reserved (alignment) | ||
87 | */ | ||
88 | uint16_t reserved_nl GNUNET_PACKED; | ||
89 | |||
90 | /** | ||
86 | * Name length | 91 | * Name length |
87 | */ | 92 | */ |
88 | uint32_t name_len; | 93 | uint16_t name_len GNUNET_PACKED; |
94 | |||
95 | /** | ||
96 | * Reserved (alignment) | ||
97 | */ | ||
98 | uint16_t reserved_ds GNUNET_PACKED; | ||
89 | 99 | ||
90 | /** | 100 | /** |
91 | * Data size | 101 | * Data size |
92 | */ | 102 | */ |
93 | uint32_t data_size; | 103 | uint16_t data_size GNUNET_PACKED; |
94 | 104 | ||
95 | // followed by data_size Presentation value data | 105 | // followed by data_size Presentation value data |
96 | }; | 106 | }; |