Skip to content

Commit

Permalink
handle windows endline
Browse files Browse the repository at this point in the history
  • Loading branch information
xiazhvera committed Oct 13, 2023
1 parent 2ce3be8 commit 14fe544
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions source/pem.c
Original file line number Diff line number Diff line change
Expand Up @@ -232,11 +232,17 @@ int s_extract_header_type_cur(struct aws_byte_cursor cur, struct aws_byte_cursor
}

aws_byte_cursor_advance(&cur, s_begin_header_cur.len);
AWS_LOGF_ERROR(AWS_LS_IO_PEM, "Invalid PEM buffer: invalid end token %d:"PRInSTR, cur.len, AWS_BYTE_CURSOR_PRI(cur));
aws_byte_cursor_advance(&cur, 1); // space after begin
AWS_LOGF_ERROR(AWS_LS_IO_PEM, "Invalid PEM buffer: invalid end token %d:"PRInSTR, cur.len, AWS_BYTE_CURSOR_PRI(cur));


/* handle CRLF on Windows by burning '\r' off the end of the buffer */
if (cur.len && (cur.ptr[cur.len- 1] == '\r')) {
cur.len--;
}

struct aws_byte_cursor type_cur = aws_byte_cursor_advance(&cur, cur.len - s_delim_cur.len);


if (!aws_byte_cursor_eq(&cur, &s_delim_cur)) {
AWS_LOGF_ERROR(AWS_LS_IO_PEM, "Invalid PEM buffer: invalid end token %d:"PRInSTR, cur.len, AWS_BYTE_CURSOR_PRI(cur));
return aws_raise_error(AWS_ERROR_PEM_MALFORMED);
Expand Down

0 comments on commit 14fe544

Please sign in to comment.