mirror of
https://github.com/ading2210/libcurl.js.git
synced 2025-05-15 07:10:01 -04:00
fix buffer overflow error and update dependencies
This commit is contained in:
parent
fe72717db8
commit
94aaca8f22
4 changed files with 14 additions and 16 deletions
|
@ -23,18 +23,18 @@ void generate_pem() {
|
|||
|
||||
//calculate total length of the pem file
|
||||
cacert_pem_len = 0;
|
||||
for (int i = 0; i < cert_count; i++) {
|
||||
int cert_len = cert_lengths[i];
|
||||
for (int i = 0; i < _cert_count; i++) {
|
||||
int cert_len = _cert_lengths[i];
|
||||
int b64_len = ((4 * cert_len / 3) + 3) & ~3;
|
||||
cacert_pem_len += begin_cert_len + end_cert_len + b64_len;
|
||||
}
|
||||
cacert_pem = malloc(cacert_pem_len);
|
||||
cacert_pem = malloc(cacert_pem_len + 1);
|
||||
|
||||
//loop for base64 encoding each part
|
||||
int offset = 0;
|
||||
for (int i = 0; i < cert_count; i++) {
|
||||
for (int i = 0; i < _cert_count; i++) {
|
||||
unsigned char* cert = _certs[i];
|
||||
int cert_len = cert_lengths[i];
|
||||
int cert_len = _cert_lengths[i];
|
||||
int b64_len = ((4 * cert_len / 3) + 3) & ~3;
|
||||
|
||||
strcpy((char*) (cacert_pem + offset), begin_cert_str);
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
import sys
|
||||
import base64
|
||||
import re
|
||||
import hashlib
|
||||
|
||||
with open(sys.argv[1]) as f:
|
||||
pem_file = f.read()
|
||||
|
@ -13,15 +12,14 @@ certs_b64 = [s.replace("\n", "") for s in certs_b64]
|
|||
|
||||
certs_str = "\n".join(cert_template.format(b64=s) for s in certs_b64)
|
||||
total_len = len(certs_str)
|
||||
print(hashlib.sha256(certs_str.encode()).hexdigest(), file=sys.stderr)
|
||||
|
||||
header_part_template = """
|
||||
static uint8_t _cert_{num}[] = {array};
|
||||
"""
|
||||
header_end_template = """
|
||||
uint8_t* _certs[] = {certs_array};
|
||||
uint16_t cert_lengths[] = {lengths_array};
|
||||
uint16_t cert_count = {cert_count};
|
||||
uint16_t _cert_lengths[] = {lengths_array};
|
||||
uint16_t _cert_count = {cert_count};
|
||||
"""
|
||||
|
||||
header_file = "#include <stdint.h>"
|
||||
|
|
|
@ -10,7 +10,7 @@ PREFIX=$(realpath build/nghttp2-wasm)
|
|||
|
||||
cd build
|
||||
rm -rf nghttp2
|
||||
git clone -b v1.63.0 --depth=1 https://github.com/nghttp2/nghttp2
|
||||
git clone -b v1.64.0 --depth=1 https://github.com/nghttp2/nghttp2
|
||||
cd nghttp2
|
||||
|
||||
rm -rf $PREFIX
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue