Skip to content

Commit 3c6d901

Browse files
Fix asn.1 parser on big endian (#228)
1 parent db463bd commit 3c6d901

File tree

3 files changed

+45
-4
lines changed

3 files changed

+45
-4
lines changed

.github/workflows/ci.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -406,3 +406,31 @@ jobs:
406406
run: |
407407
aws s3 cp s3://aws-crt-test-stuff/ci/${{ env.BUILDER_VERSION }}/linux-container-ci.sh ./linux-container-ci.sh && chmod a+x ./linux-container-ci.sh
408408
./linux-container-ci.sh ${{ env.BUILDER_VERSION }} aws-crt-${{ env.LINUX_BASE_IMAGE }} build -p ${{ env.PACKAGE_NAME }} --variant=no-tests --cmake-extra=-DBYO_CRYPTO=ON
409+
410+
s390x: # big-endian
411+
runs-on: ubuntu-24.04
412+
steps:
413+
- uses: aws-actions/configure-aws-credentials@v4
414+
with:
415+
role-to-assume: ${{ env.CRT_CI_ROLE }}
416+
aws-region: ${{ env.AWS_DEFAULT_REGION }}
417+
- uses: actions/checkout@v4
418+
- uses: uraimo/run-on-arch-action@v3
419+
name: Run commands
420+
id: runcmd
421+
with:
422+
arch: s390x
423+
distro: ubuntu22.04
424+
install: |
425+
apt-get update -q -y
426+
apt-get -y install sudo
427+
apt-get -y install cmake
428+
apt-get -y install make
429+
apt-get -y install g++
430+
apt-get -y install python3
431+
apt-get -y install git
432+
run: |
433+
lscpu | grep Endian
434+
python3 -c "from urllib.request import urlretrieve; urlretrieve('${{ env.BUILDER_HOST }}/${{ env.BUILDER_SOURCE }}/${{ env.BUILDER_VERSION }}/builder.pyz?run=${{ env.RUN }}', 'builder')"
435+
chmod a+x builder
436+
./builder build -p ${{ env.PACKAGE_NAME }} --variant s390x --cmake-extra=-DENABLE_SANITIZERS=OFF

builder.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,13 @@
145145
"!test_steps": [
146146
"test"
147147
]
148+
},
149+
"s390x": {
150+
"hosts": {
151+
"ubuntu": {
152+
"!pkg_setup": []
153+
}
154+
}
148155
}
149156
},
150157
"test_steps": [

source/der.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -80,16 +80,22 @@ static int s_der_read_tlv(struct aws_byte_cursor *cur, struct der_tlv *tlv) {
8080
if (len_bytes & 0x80) {
8181
len_bytes &= 0x7f;
8282
switch (len_bytes) {
83-
case 1:
84-
if (!aws_byte_cursor_read_u8(cur, (uint8_t *)&len)) {
83+
case 1: {
84+
uint8_t len_u8;
85+
if (!aws_byte_cursor_read_u8(cur, &len_u8)) {
8586
return aws_raise_error(AWS_ERROR_CAL_MALFORMED_ASN1_ENCOUNTERED);
8687
}
88+
len = len_u8;
8789
break;
88-
case 2:
89-
if (!aws_byte_cursor_read_be16(cur, (uint16_t *)&len)) {
90+
}
91+
case 2: {
92+
uint16_t len_u16;
93+
if (!aws_byte_cursor_read_be16(cur, &len_u16)) {
9094
return aws_raise_error(AWS_ERROR_CAL_MALFORMED_ASN1_ENCOUNTERED);
9195
}
96+
len = len_u16;
9297
break;
98+
}
9399
case 4:
94100
if (!aws_byte_cursor_read_be32(cur, &len)) {
95101
return aws_raise_error(AWS_ERROR_CAL_MALFORMED_ASN1_ENCOUNTERED);

0 commit comments

Comments
 (0)