diff options
Diffstat (limited to 'src/reclaim/plugin_reclaim_credential_jwt.c')
-rw-r--r-- | src/reclaim/plugin_reclaim_credential_jwt.c | 27 |
1 files changed, 15 insertions, 12 deletions
diff --git a/src/reclaim/plugin_reclaim_credential_jwt.c b/src/reclaim/plugin_reclaim_credential_jwt.c index 6f52f3a4e..f30ead570 100644 --- a/src/reclaim/plugin_reclaim_credential_jwt.c +++ b/src/reclaim/plugin_reclaim_credential_jwt.c | |||
@@ -81,7 +81,7 @@ jwt_string_to_value (void *cls, | |||
81 | { | 81 | { |
82 | case GNUNET_RECLAIM_CREDENTIAL_TYPE_JWT: | 82 | case GNUNET_RECLAIM_CREDENTIAL_TYPE_JWT: |
83 | *data = GNUNET_strdup (s); | 83 | *data = GNUNET_strdup (s); |
84 | *data_size = strlen (s); | 84 | *data_size = strlen (s) + 1; |
85 | return GNUNET_OK; | 85 | return GNUNET_OK; |
86 | 86 | ||
87 | default: | 87 | default: |
@@ -151,7 +151,8 @@ jwt_number_to_typename (void *cls, uint32_t type) | |||
151 | */ | 151 | */ |
152 | struct GNUNET_RECLAIM_AttributeList * | 152 | struct GNUNET_RECLAIM_AttributeList * |
153 | jwt_parse_attributes (void *cls, | 153 | jwt_parse_attributes (void *cls, |
154 | const char *data) | 154 | const char *data, |
155 | size_t data_size) | ||
155 | { | 156 | { |
156 | char *jwt_string; | 157 | char *jwt_string; |
157 | struct GNUNET_RECLAIM_AttributeList *attrs; | 158 | struct GNUNET_RECLAIM_AttributeList *attrs; |
@@ -164,7 +165,7 @@ jwt_parse_attributes (void *cls, | |||
164 | 165 | ||
165 | attrs = GNUNET_new (struct GNUNET_RECLAIM_AttributeList); | 166 | attrs = GNUNET_new (struct GNUNET_RECLAIM_AttributeList); |
166 | 167 | ||
167 | jwt_string = GNUNET_strdup (data); | 168 | jwt_string = GNUNET_strndup (data, data_size); |
168 | const char *jwt_body = strtok (jwt_string, delim); | 169 | const char *jwt_body = strtok (jwt_string, delim); |
169 | jwt_body = strtok (NULL, delim); | 170 | jwt_body = strtok (NULL, delim); |
170 | GNUNET_STRINGS_base64url_decode (jwt_body, strlen (jwt_body), | 171 | GNUNET_STRINGS_base64url_decode (jwt_body, strlen (jwt_body), |
@@ -212,7 +213,7 @@ struct GNUNET_RECLAIM_AttributeList * | |||
212 | jwt_parse_attributes_c (void *cls, | 213 | jwt_parse_attributes_c (void *cls, |
213 | const struct GNUNET_RECLAIM_Credential *cred) | 214 | const struct GNUNET_RECLAIM_Credential *cred) |
214 | { | 215 | { |
215 | return jwt_parse_attributes (cls, cred->data); | 216 | return jwt_parse_attributes (cls, cred->data, cred->data_size); |
216 | } | 217 | } |
217 | 218 | ||
218 | 219 | ||
@@ -227,7 +228,7 @@ struct GNUNET_RECLAIM_AttributeList * | |||
227 | jwt_parse_attributes_p (void *cls, | 228 | jwt_parse_attributes_p (void *cls, |
228 | const struct GNUNET_RECLAIM_Presentation *cred) | 229 | const struct GNUNET_RECLAIM_Presentation *cred) |
229 | { | 230 | { |
230 | return jwt_parse_attributes (cls, cred->data); | 231 | return jwt_parse_attributes (cls, cred->data, cred->data_size); |
231 | } | 232 | } |
232 | 233 | ||
233 | 234 | ||
@@ -240,7 +241,8 @@ jwt_parse_attributes_p (void *cls, | |||
240 | */ | 241 | */ |
241 | char * | 242 | char * |
242 | jwt_get_issuer (void *cls, | 243 | jwt_get_issuer (void *cls, |
243 | const char *data) | 244 | const char *data, |
245 | size_t data_size) | ||
244 | { | 246 | { |
245 | const char *jwt_body; | 247 | const char *jwt_body; |
246 | char *jwt_string; | 248 | char *jwt_string; |
@@ -252,7 +254,7 @@ jwt_get_issuer (void *cls, | |||
252 | json_t *json_val; | 254 | json_t *json_val; |
253 | json_error_t *json_err = NULL; | 255 | json_error_t *json_err = NULL; |
254 | 256 | ||
255 | jwt_string = GNUNET_strdup (data); | 257 | jwt_string = GNUNET_strndup (data, data_size); |
256 | jwt_body = strtok (jwt_string, delim); | 258 | jwt_body = strtok (jwt_string, delim); |
257 | jwt_body = strtok (NULL, delim); | 259 | jwt_body = strtok (NULL, delim); |
258 | GNUNET_STRINGS_base64url_decode (jwt_body, strlen (jwt_body), | 260 | GNUNET_STRINGS_base64url_decode (jwt_body, strlen (jwt_body), |
@@ -280,7 +282,7 @@ jwt_get_issuer_c (void *cls, | |||
280 | { | 282 | { |
281 | if (GNUNET_RECLAIM_CREDENTIAL_TYPE_JWT != cred->type) | 283 | if (GNUNET_RECLAIM_CREDENTIAL_TYPE_JWT != cred->type) |
282 | return NULL; | 284 | return NULL; |
283 | return jwt_get_issuer (cls, cred->data); | 285 | return jwt_get_issuer (cls, cred->data, cred->data_size); |
284 | } | 286 | } |
285 | 287 | ||
286 | 288 | ||
@@ -297,7 +299,7 @@ jwt_get_issuer_p (void *cls, | |||
297 | { | 299 | { |
298 | if (GNUNET_RECLAIM_CREDENTIAL_TYPE_JWT != cred->type) | 300 | if (GNUNET_RECLAIM_CREDENTIAL_TYPE_JWT != cred->type) |
299 | return NULL; | 301 | return NULL; |
300 | return jwt_get_issuer (cls, cred->data); | 302 | return jwt_get_issuer (cls, cred->data, cred->data_size); |
301 | } | 303 | } |
302 | 304 | ||
303 | 305 | ||
@@ -311,6 +313,7 @@ jwt_get_issuer_p (void *cls, | |||
311 | int | 313 | int |
312 | jwt_get_expiration (void *cls, | 314 | jwt_get_expiration (void *cls, |
313 | const char *data, | 315 | const char *data, |
316 | size_t data_size, | ||
314 | struct GNUNET_TIME_Absolute *exp) | 317 | struct GNUNET_TIME_Absolute *exp) |
315 | { | 318 | { |
316 | const char *jwt_body; | 319 | const char *jwt_body; |
@@ -322,7 +325,7 @@ jwt_get_expiration (void *cls, | |||
322 | json_t *json_val; | 325 | json_t *json_val; |
323 | json_error_t *json_err = NULL; | 326 | json_error_t *json_err = NULL; |
324 | 327 | ||
325 | jwt_string = GNUNET_strdup (data); | 328 | jwt_string = GNUNET_strndup (data, data_size); |
326 | jwt_body = strtok (jwt_string, delim); | 329 | jwt_body = strtok (jwt_string, delim); |
327 | jwt_body = strtok (NULL, delim); | 330 | jwt_body = strtok (NULL, delim); |
328 | GNUNET_STRINGS_base64url_decode (jwt_body, strlen (jwt_body), | 331 | GNUNET_STRINGS_base64url_decode (jwt_body, strlen (jwt_body), |
@@ -349,7 +352,7 @@ jwt_get_expiration_c (void *cls, | |||
349 | const struct GNUNET_RECLAIM_Credential *cred, | 352 | const struct GNUNET_RECLAIM_Credential *cred, |
350 | struct GNUNET_TIME_Absolute *exp) | 353 | struct GNUNET_TIME_Absolute *exp) |
351 | { | 354 | { |
352 | return jwt_get_expiration (cls, cred->data, exp); | 355 | return jwt_get_expiration (cls, cred->data, cred->data_size, exp); |
353 | } | 356 | } |
354 | 357 | ||
355 | 358 | ||
@@ -365,7 +368,7 @@ jwt_get_expiration_p (void *cls, | |||
365 | const struct GNUNET_RECLAIM_Presentation *cred, | 368 | const struct GNUNET_RECLAIM_Presentation *cred, |
366 | struct GNUNET_TIME_Absolute *exp) | 369 | struct GNUNET_TIME_Absolute *exp) |
367 | { | 370 | { |
368 | return jwt_get_expiration (cls, cred->data, exp); | 371 | return jwt_get_expiration (cls, cred->data, cred->data_size, exp); |
369 | } | 372 | } |
370 | 373 | ||
371 | 374 | ||