Skip to content

Commit

Permalink
Merge pull request aws#1385 from justsmth/upstream-merge-2024-01-05
Browse files Browse the repository at this point in the history
Upstream merge 2024 01 05
  • Loading branch information
justsmth authored Jan 12, 2024
2 parents f7798b7 + 974956e commit d9caaca
Show file tree
Hide file tree
Showing 33 changed files with 497 additions and 167 deletions.
1 change: 1 addition & 0 deletions crypto/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,7 @@ add_library(
bio/bio.c
bio/bio_mem.c
bio/connect.c
bio/errno.c
bio/fd.c
bio/file.c
bio/hexdump.c
Expand Down
10 changes: 7 additions & 3 deletions crypto/asn1/a_gentm.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
#include <openssl/err.h>
#include <openssl/mem.h>

#include <stdlib.h>
#include <string.h>
#include <time.h>

Expand Down Expand Up @@ -122,9 +123,12 @@ ASN1_GENERALIZEDTIME *ASN1_GENERALIZEDTIME_adj(ASN1_GENERALIZEDTIME *s,
}

char buf[16];
BIO_snprintf(buf, sizeof(buf), "%04d%02d%02d%02d%02d%02dZ",
data.tm_year + 1900, data.tm_mon + 1, data.tm_mday, data.tm_hour,
data.tm_min, data.tm_sec);
int ret = snprintf(buf, sizeof(buf), "%04d%02d%02d%02d%02d%02dZ",
data.tm_year + 1900, data.tm_mon + 1, data.tm_mday,
data.tm_hour, data.tm_min, data.tm_sec);
if (ret != (int)(sizeof(buf) - 1)) {
abort(); // |snprintf| should neither truncate nor write fewer bytes.
}

int free_s = 0;
if (s == NULL) {
Expand Down
14 changes: 7 additions & 7 deletions crypto/asn1/a_strex.c
Original file line number Diff line number Diff line change
Expand Up @@ -88,18 +88,18 @@ static int do_esc_char(uint32_t c, unsigned long flags, char *do_quotes,
char buf[16]; // Large enough for "\\W01234567".
unsigned char u8 = (unsigned char)c;
if (c > 0xffff) {
BIO_snprintf(buf, sizeof(buf), "\\W%08" PRIX32, c);
snprintf(buf, sizeof(buf), "\\W%08" PRIX32, c);
} else if (c > 0xff) {
BIO_snprintf(buf, sizeof(buf), "\\U%04" PRIX32, c);
snprintf(buf, sizeof(buf), "\\U%04" PRIX32, c);
} else if ((flags & ASN1_STRFLGS_ESC_MSB) && c > 0x7f) {
BIO_snprintf(buf, sizeof(buf), "\\%02X", c);
snprintf(buf, sizeof(buf), "\\%02X", c);
} else if ((flags & ASN1_STRFLGS_ESC_CTRL) && is_control_character(c)) {
BIO_snprintf(buf, sizeof(buf), "\\%02X", c);
snprintf(buf, sizeof(buf), "\\%02X", c);
} else if (flags & ASN1_STRFLGS_ESC_2253) {
// See RFC 2253, sections 2.4 and 4.
if (c == '\\' || c == '"') {
// Quotes and backslashes are always escaped, quoted or not.
BIO_snprintf(buf, sizeof(buf), "\\%c", (int)c);
snprintf(buf, sizeof(buf), "\\%c", (int)c);
} else if (c == ',' || c == '+' || c == '<' || c == '>' || c == ';' ||
(is_first && (c == ' ' || c == '#')) ||
(is_last && (c == ' '))) {
Expand All @@ -110,13 +110,13 @@ static int do_esc_char(uint32_t c, unsigned long flags, char *do_quotes,
}
return maybe_write(out, &u8, 1) ? 1 : -1;
}
BIO_snprintf(buf, sizeof(buf), "\\%c", (int)c);
snprintf(buf, sizeof(buf), "\\%c", (int)c);
} else {
return maybe_write(out, &u8, 1) ? 1 : -1;
}
} else if ((flags & ESC_FLAGS) && c == '\\') {
// If any escape flags are set, also escape backslashes.
BIO_snprintf(buf, sizeof(buf), "\\%c", (int)c);
snprintf(buf, sizeof(buf), "\\%c", (int)c);
} else {
return maybe_write(out, &u8, 1) ? 1 : -1;
}
Expand Down
10 changes: 7 additions & 3 deletions crypto/asn1/a_utctm.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
#include <openssl/err.h>
#include <openssl/mem.h>

#include <stdlib.h>
#include <string.h>
#include <time.h>

Expand Down Expand Up @@ -123,9 +124,12 @@ ASN1_UTCTIME *ASN1_UTCTIME_adj(ASN1_UTCTIME *s, int64_t posix_time, int offset_d
}

char buf[14];
BIO_snprintf(buf, sizeof(buf), "%02d%02d%02d%02d%02d%02dZ",
data.tm_year % 100, data.tm_mon + 1, data.tm_mday, data.tm_hour,
data.tm_min, data.tm_sec);
int ret = snprintf(buf, sizeof(buf), "%02d%02d%02d%02d%02d%02dZ",
data.tm_year % 100, data.tm_mon + 1, data.tm_mday,
data.tm_hour, data.tm_min, data.tm_sec);
if (ret != (int)(sizeof(buf) - 1)) {
abort(); // |snprintf| should neither truncate nor write fewer bytes.
}

int free_s = 0;
if (s == NULL) {
Expand Down
Loading

0 comments on commit d9caaca

Please sign in to comment.