diff options
-rw-r--r-- | src/lib/libssl/bs_cbb.c | 28 | ||||
-rw-r--r-- | src/lib/libssl/bytestring.h | 10 | ||||
-rw-r--r-- | src/lib/libssl/src/ssl/bs_cbb.c | 28 | ||||
-rw-r--r-- | src/lib/libssl/src/ssl/bytestring.h | 10 |
4 files changed, 50 insertions, 26 deletions
diff --git a/src/lib/libssl/bs_cbb.c b/src/lib/libssl/bs_cbb.c index e86bb926ab..441141734b 100644 --- a/src/lib/libssl/bs_cbb.c +++ b/src/lib/libssl/bs_cbb.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: bs_cbb.c,v 1.11 2015/06/13 09:24:12 doug Exp $ */ | 1 | /* $OpenBSD: bs_cbb.c,v 1.12 2015/06/18 23:25:07 doug Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2014, Google Inc. | 3 | * Copyright (c) 2014, Google Inc. |
4 | * | 4 | * |
@@ -304,8 +304,11 @@ CBB_add_u24_length_prefixed(CBB *cbb, CBB *out_contents) | |||
304 | } | 304 | } |
305 | 305 | ||
306 | int | 306 | int |
307 | CBB_add_asn1(CBB *cbb, CBB *out_contents, uint8_t tag) | 307 | CBB_add_asn1(CBB *cbb, CBB *out_contents, unsigned int tag) |
308 | { | 308 | { |
309 | if (tag > UINT8_MAX) | ||
310 | return 0; | ||
311 | |||
309 | /* Long form identifier octets are not supported. */ | 312 | /* Long form identifier octets are not supported. */ |
310 | if ((tag & 0x1f) == 0x1f) | 313 | if ((tag & 0x1f) == 0x1f) |
311 | return 0; | 314 | return 0; |
@@ -353,21 +356,30 @@ CBB_add_space(CBB *cbb, uint8_t **out_data, size_t len) | |||
353 | } | 356 | } |
354 | 357 | ||
355 | int | 358 | int |
356 | CBB_add_u8(CBB *cbb, uint8_t value) | 359 | CBB_add_u8(CBB *cbb, size_t value) |
357 | { | 360 | { |
358 | return cbb_add_u(cbb, value, 1); | 361 | if (value > UINT8_MAX) |
362 | return 0; | ||
363 | |||
364 | return cbb_add_u(cbb, (uint32_t)value, 1); | ||
359 | } | 365 | } |
360 | 366 | ||
361 | int | 367 | int |
362 | CBB_add_u16(CBB *cbb, uint16_t value) | 368 | CBB_add_u16(CBB *cbb, size_t value) |
363 | { | 369 | { |
364 | return cbb_add_u(cbb, value, 2); | 370 | if (value > UINT16_MAX) |
371 | return 0; | ||
372 | |||
373 | return cbb_add_u(cbb, (uint32_t)value, 2); | ||
365 | } | 374 | } |
366 | 375 | ||
367 | int | 376 | int |
368 | CBB_add_u24(CBB *cbb, uint32_t value) | 377 | CBB_add_u24(CBB *cbb, size_t value) |
369 | { | 378 | { |
370 | return cbb_add_u(cbb, value, 3); | 379 | if (value > 0xffffffUL) |
380 | return 0; | ||
381 | |||
382 | return cbb_add_u(cbb, (uint32_t)value, 3); | ||
371 | } | 383 | } |
372 | 384 | ||
373 | int | 385 | int |
diff --git a/src/lib/libssl/bytestring.h b/src/lib/libssl/bytestring.h index e831706b28..4c9d4d8884 100644 --- a/src/lib/libssl/bytestring.h +++ b/src/lib/libssl/bytestring.h | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: bytestring.h,v 1.12 2015/06/17 07:25:56 doug Exp $ */ | 1 | /* $OpenBSD: bytestring.h,v 1.13 2015/06/18 23:25:07 doug Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2014, Google Inc. | 3 | * Copyright (c) 2014, Google Inc. |
4 | * | 4 | * |
@@ -423,7 +423,7 @@ int CBB_add_u24_length_prefixed(CBB *cbb, CBB *out_contents); | |||
423 | * single octet identifiers are supported. It returns one on success or zero | 423 | * single octet identifiers are supported. It returns one on success or zero |
424 | * on error. | 424 | * on error. |
425 | */ | 425 | */ |
426 | int CBB_add_asn1(CBB *cbb, CBB *out_contents, uint8_t tag); | 426 | int CBB_add_asn1(CBB *cbb, CBB *out_contents, unsigned int tag); |
427 | 427 | ||
428 | /* | 428 | /* |
429 | * CBB_add_bytes appends |len| bytes from |data| to |cbb|. It returns one on | 429 | * CBB_add_bytes appends |len| bytes from |data| to |cbb|. It returns one on |
@@ -443,19 +443,19 @@ int CBB_add_space(CBB *cbb, uint8_t **out_data, size_t len); | |||
443 | * CBB_add_u8 appends an 8-bit number from |value| to |cbb|. It returns one on | 443 | * CBB_add_u8 appends an 8-bit number from |value| to |cbb|. It returns one on |
444 | * success and zero otherwise. | 444 | * success and zero otherwise. |
445 | */ | 445 | */ |
446 | int CBB_add_u8(CBB *cbb, uint8_t value); | 446 | int CBB_add_u8(CBB *cbb, size_t value); |
447 | 447 | ||
448 | /* | 448 | /* |
449 | * CBB_add_u8 appends a 16-bit, big-endian number from |value| to |cbb|. It | 449 | * CBB_add_u8 appends a 16-bit, big-endian number from |value| to |cbb|. It |
450 | * returns one on success and zero otherwise. | 450 | * returns one on success and zero otherwise. |
451 | */ | 451 | */ |
452 | int CBB_add_u16(CBB *cbb, uint16_t value); | 452 | int CBB_add_u16(CBB *cbb, size_t value); |
453 | 453 | ||
454 | /* | 454 | /* |
455 | * CBB_add_u24 appends a 24-bit, big-endian number from |value| to |cbb|. It | 455 | * CBB_add_u24 appends a 24-bit, big-endian number from |value| to |cbb|. It |
456 | * returns one on success and zero otherwise. | 456 | * returns one on success and zero otherwise. |
457 | */ | 457 | */ |
458 | int CBB_add_u24(CBB *cbb, uint32_t value); | 458 | int CBB_add_u24(CBB *cbb, size_t value); |
459 | 459 | ||
460 | /* | 460 | /* |
461 | * CBB_add_asn1_uint64 writes an ASN.1 INTEGER into |cbb| using |CBB_add_asn1| | 461 | * CBB_add_asn1_uint64 writes an ASN.1 INTEGER into |cbb| using |CBB_add_asn1| |
diff --git a/src/lib/libssl/src/ssl/bs_cbb.c b/src/lib/libssl/src/ssl/bs_cbb.c index e86bb926ab..441141734b 100644 --- a/src/lib/libssl/src/ssl/bs_cbb.c +++ b/src/lib/libssl/src/ssl/bs_cbb.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: bs_cbb.c,v 1.11 2015/06/13 09:24:12 doug Exp $ */ | 1 | /* $OpenBSD: bs_cbb.c,v 1.12 2015/06/18 23:25:07 doug Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2014, Google Inc. | 3 | * Copyright (c) 2014, Google Inc. |
4 | * | 4 | * |
@@ -304,8 +304,11 @@ CBB_add_u24_length_prefixed(CBB *cbb, CBB *out_contents) | |||
304 | } | 304 | } |
305 | 305 | ||
306 | int | 306 | int |
307 | CBB_add_asn1(CBB *cbb, CBB *out_contents, uint8_t tag) | 307 | CBB_add_asn1(CBB *cbb, CBB *out_contents, unsigned int tag) |
308 | { | 308 | { |
309 | if (tag > UINT8_MAX) | ||
310 | return 0; | ||
311 | |||
309 | /* Long form identifier octets are not supported. */ | 312 | /* Long form identifier octets are not supported. */ |
310 | if ((tag & 0x1f) == 0x1f) | 313 | if ((tag & 0x1f) == 0x1f) |
311 | return 0; | 314 | return 0; |
@@ -353,21 +356,30 @@ CBB_add_space(CBB *cbb, uint8_t **out_data, size_t len) | |||
353 | } | 356 | } |
354 | 357 | ||
355 | int | 358 | int |
356 | CBB_add_u8(CBB *cbb, uint8_t value) | 359 | CBB_add_u8(CBB *cbb, size_t value) |
357 | { | 360 | { |
358 | return cbb_add_u(cbb, value, 1); | 361 | if (value > UINT8_MAX) |
362 | return 0; | ||
363 | |||
364 | return cbb_add_u(cbb, (uint32_t)value, 1); | ||
359 | } | 365 | } |
360 | 366 | ||
361 | int | 367 | int |
362 | CBB_add_u16(CBB *cbb, uint16_t value) | 368 | CBB_add_u16(CBB *cbb, size_t value) |
363 | { | 369 | { |
364 | return cbb_add_u(cbb, value, 2); | 370 | if (value > UINT16_MAX) |
371 | return 0; | ||
372 | |||
373 | return cbb_add_u(cbb, (uint32_t)value, 2); | ||
365 | } | 374 | } |
366 | 375 | ||
367 | int | 376 | int |
368 | CBB_add_u24(CBB *cbb, uint32_t value) | 377 | CBB_add_u24(CBB *cbb, size_t value) |
369 | { | 378 | { |
370 | return cbb_add_u(cbb, value, 3); | 379 | if (value > 0xffffffUL) |
380 | return 0; | ||
381 | |||
382 | return cbb_add_u(cbb, (uint32_t)value, 3); | ||
371 | } | 383 | } |
372 | 384 | ||
373 | int | 385 | int |
diff --git a/src/lib/libssl/src/ssl/bytestring.h b/src/lib/libssl/src/ssl/bytestring.h index e831706b28..4c9d4d8884 100644 --- a/src/lib/libssl/src/ssl/bytestring.h +++ b/src/lib/libssl/src/ssl/bytestring.h | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: bytestring.h,v 1.12 2015/06/17 07:25:56 doug Exp $ */ | 1 | /* $OpenBSD: bytestring.h,v 1.13 2015/06/18 23:25:07 doug Exp $ */ |
2 | /* | 2 | /* |
3 | * Copyright (c) 2014, Google Inc. | 3 | * Copyright (c) 2014, Google Inc. |
4 | * | 4 | * |
@@ -423,7 +423,7 @@ int CBB_add_u24_length_prefixed(CBB *cbb, CBB *out_contents); | |||
423 | * single octet identifiers are supported. It returns one on success or zero | 423 | * single octet identifiers are supported. It returns one on success or zero |
424 | * on error. | 424 | * on error. |
425 | */ | 425 | */ |
426 | int CBB_add_asn1(CBB *cbb, CBB *out_contents, uint8_t tag); | 426 | int CBB_add_asn1(CBB *cbb, CBB *out_contents, unsigned int tag); |
427 | 427 | ||
428 | /* | 428 | /* |
429 | * CBB_add_bytes appends |len| bytes from |data| to |cbb|. It returns one on | 429 | * CBB_add_bytes appends |len| bytes from |data| to |cbb|. It returns one on |
@@ -443,19 +443,19 @@ int CBB_add_space(CBB *cbb, uint8_t **out_data, size_t len); | |||
443 | * CBB_add_u8 appends an 8-bit number from |value| to |cbb|. It returns one on | 443 | * CBB_add_u8 appends an 8-bit number from |value| to |cbb|. It returns one on |
444 | * success and zero otherwise. | 444 | * success and zero otherwise. |
445 | */ | 445 | */ |
446 | int CBB_add_u8(CBB *cbb, uint8_t value); | 446 | int CBB_add_u8(CBB *cbb, size_t value); |
447 | 447 | ||
448 | /* | 448 | /* |
449 | * CBB_add_u8 appends a 16-bit, big-endian number from |value| to |cbb|. It | 449 | * CBB_add_u8 appends a 16-bit, big-endian number from |value| to |cbb|. It |
450 | * returns one on success and zero otherwise. | 450 | * returns one on success and zero otherwise. |
451 | */ | 451 | */ |
452 | int CBB_add_u16(CBB *cbb, uint16_t value); | 452 | int CBB_add_u16(CBB *cbb, size_t value); |
453 | 453 | ||
454 | /* | 454 | /* |
455 | * CBB_add_u24 appends a 24-bit, big-endian number from |value| to |cbb|. It | 455 | * CBB_add_u24 appends a 24-bit, big-endian number from |value| to |cbb|. It |
456 | * returns one on success and zero otherwise. | 456 | * returns one on success and zero otherwise. |
457 | */ | 457 | */ |
458 | int CBB_add_u24(CBB *cbb, uint32_t value); | 458 | int CBB_add_u24(CBB *cbb, size_t value); |
459 | 459 | ||
460 | /* | 460 | /* |
461 | * CBB_add_asn1_uint64 writes an ASN.1 INTEGER into |cbb| using |CBB_add_asn1| | 461 | * CBB_add_asn1_uint64 writes an ASN.1 INTEGER into |cbb| using |CBB_add_asn1| |