Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .github/workflows/debian-package-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ jobs:
- name: wolfssl install
working-directory: ./wolfssl
run: |
sudo dpkg -i libwolfssl_*.deb libwolfssl-dev_*.deb
# Install wolfSSL packages staged in parent directory by dpkg-buildpackage
sudo dpkg -i ../libwolfssl_*.deb ../libwolfssl-dev_*.deb
sudo apt-get -f install -y

# Setup wolfPKCS11
- name: wolfpkcs11 autogen
Expand All @@ -62,6 +64,7 @@ jobs:
- name: Test debian package installation
run: |
sudo dpkg -i libwolfpkcs11_*.deb libwolfpkcs11-dev_*.deb
sudo apt-get -f install -y

# Verify installation
- name: Verify package installation
Expand Down
31 changes: 2 additions & 29 deletions .github/workflows/nss-ssltap-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,8 @@ jobs:
run: |
mkdir -p /tmp/src
cd /tmp/src
# Defensive cleanup to avoid 'destination ... is not empty' errors
rm -rf nss osp

# Clone official Mozilla NSS with specific tag
hg clone https://hg.mozilla.org/projects/nss -r ${{ env.NSS_VERSION }}
Expand Down Expand Up @@ -125,36 +127,7 @@ jobs:
path: /tmp/src/dist
key: nss-build-${{ env.NSS_VERSION }}-latest

- name: Clone NSS and apply wolfSSL patches
if: steps.cache-nss-source.outputs.cache-hit != 'true'
run: |
mkdir -p /tmp/src
cd /tmp/src

# Clone official Mozilla NSS with specific tag
hg clone https://hg.mozilla.org/projects/nss -r ${{ env.NSS_VERSION }}

# Clone wolfSSL OSP repository for patches
git clone https://github.com/wolfSSL/osp.git

cd nss

# Apply patches from wolfSSL/osp/nss directory
echo "Applying wolfSSL NSS patches..."
if [ -d "../osp/nss" ]; then
for patch in ../osp/nss/*.patch; do
if [ -f "$patch" ]; then
echo "Applying patch: $(basename $patch)"
patch -p1 < "$patch" || {
echo "Warning: Patch $(basename $patch) failed to apply cleanly"
echo "Attempting to apply with --reject-file option..."
patch -p1 --reject-file=/tmp/$(basename $patch).rej < "$patch" || true
}
fi
done
else
echo "No patches found in wolfSSL/osp/nss directory"
fi

- name: Build NSS
if: steps.cache-nss-build.outputs.cache-hit != 'true'
Expand Down
14 changes: 12 additions & 2 deletions src/internal.c
Original file line number Diff line number Diff line change
Expand Up @@ -1064,7 +1064,11 @@ static int wolfPKCS11_Store_Name(int type, CK_ULONG id1, CK_ULONG id2, char* nam
#ifndef WOLFPKCS11_NO_ENV
const char* str = NULL;
#endif
char homePath[47]; /* Must fit within name buffer size limit */
/* Reserve enough space in the final filename for suffixes such as
* "/wp11_rsakey_priv_%016lx_%016lx" (47 chars worst-case).
*/
enum { WP11_STORE_SUFFIX_RESERVE = 48 };
char homePath[256];

/* Path order:
* 1. Environment variable WOLFPKCS11_TOKEN_PATH
Expand Down Expand Up @@ -1125,7 +1129,13 @@ static int wolfPKCS11_Store_Name(int type, CK_ULONG id1, CK_ULONG id2, char* nam
#endif

/* 47 is maximum number of character to a filename and path separator. */
if (str == NULL || (XSTRLEN(str) > nameLen - sizeof(homePath))) {
if (str == NULL) {
return -1;
}
if (nameLen <= WP11_STORE_SUFFIX_RESERVE) {
return -1;
}
if (XSTRLEN(str) > (size_t)(nameLen - WP11_STORE_SUFFIX_RESERVE - 1)) {
return -1;
}

Expand Down
Loading