Skip to content

Commit db96a1c

Browse files
authored
Merge pull request #22 from cen1/chores/2026
Chores 2026
2 parents 2993cef + 3c82b0b commit db96a1c

8 files changed

Lines changed: 40 additions & 276 deletions

File tree

.github/workflows/cmake.yml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ jobs:
1010
if: true
1111
runs-on: ubuntu-latest
1212
container:
13-
image: debian:bookworm
13+
image: debian:trixie
1414

1515
steps:
16-
- uses: actions/checkout@v4
16+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
1717

1818
- name: Install dependencies
1919
run: apt-get -y update && apt-get install -y libgmp-dev build-essential cmake
@@ -43,10 +43,10 @@ jobs:
4343
if: true
4444
runs-on: ubuntu-latest
4545
container:
46-
image: debian:bookworm
46+
image: debian:trixie
4747

4848
steps:
49-
- uses: actions/checkout@v4
49+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
5050

5151
- name: Install dependencies
5252
run: apt-get -y update && apt-get install -y python3 python3-pip build-essential cmake
@@ -75,7 +75,7 @@ jobs:
7575
image: fedora:latest
7676

7777
steps:
78-
- uses: actions/checkout@v4
78+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
7979

8080
- name: Install dependencies
8181
run: dnf -y install gmp-devel make automake clang cmake
@@ -91,15 +91,15 @@ jobs:
9191
runs-on: windows-latest
9292

9393
steps:
94-
- uses: actions/checkout@v4
94+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
9595

96-
- uses: TheMrMilchmann/setup-msvc-dev@v3
96+
- uses: TheMrMilchmann/setup-msvc-dev@79dac248aac9d0059f86eae9d8b5bfab4e95e97c # v4
9797
with:
9898
arch: x64
9999

100100
- name: Install Conan
101101
id: conan
102-
uses: turtlebrowser/get-conan@main
102+
uses: turtlebrowser/get-conan@c171f295f3f507360ee018736a6608731aa2109d # v1.2
103103

104104
- name: Init conan
105105
run: conan profile detect

.github/workflows/release.yml

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ jobs:
1313
if: true
1414
runs-on: ubuntu-latest
1515
container:
16-
image: debian:bookworm
16+
image: debian:trixie
1717

1818
steps:
19-
- uses: actions/checkout@v4
19+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
2020

2121
- name: Install dependencies
2222
run: apt-get -y update && apt-get install -y libgmp-dev build-essential cmake
@@ -33,7 +33,7 @@ jobs:
3333
run: |
3434
cpack -G "DEB" -D CPACK_PACKAGE_FILE_NAME=libbncsutil-dev_${{ github.ref_name }}_amd64
3535
36-
- uses: actions/upload-artifact@v4
36+
- uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7
3737
with:
3838
retention-days: 1
3939
overwrite: true
@@ -47,7 +47,7 @@ jobs:
4747
image: fedora:latest
4848

4949
steps:
50-
- uses: actions/checkout@v4
50+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
5151

5252
- name: Install dependencies
5353
run: dnf -y install gmp-devel make automake clang cmake rpm-build
@@ -62,7 +62,7 @@ jobs:
6262
working-directory: build
6363
run: cpack -G "RPM" -D CPACK_PACKAGE_FILE_NAME=libbncsutil-devel-${{ github.ref_name }}.x86_64
6464

65-
- uses: actions/upload-artifact@v4
65+
- uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7
6666
with:
6767
retention-days: 1
6868
overwrite: true
@@ -74,22 +74,22 @@ jobs:
7474
runs-on: windows-latest
7575

7676
steps:
77-
- uses: actions/checkout@v4
77+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
7878

79-
- uses: TheMrMilchmann/setup-msvc-dev@v3
79+
- uses: TheMrMilchmann/setup-msvc-dev@79dac248aac9d0059f86eae9d8b5bfab4e95e97c # v4
8080
with:
8181
arch: x64
8282

8383
- name: Cache Conan
84-
uses: actions/cache@v3
84+
uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5
8585
with:
8686
key: conan-windows-amd64-${{ hashFiles('conanfile.py') }}
8787
path: |
8888
~/.conan2/p
8989
9090
- name: Install Conan
9191
id: conan
92-
uses: turtlebrowser/get-conan@main
92+
uses: turtlebrowser/get-conan@c171f295f3f507360ee018736a6608731aa2109d # v1.2
9393

9494
- name: Init conan
9595
run: conan profile detect
@@ -111,7 +111,7 @@ jobs:
111111
Compress-Archive -Path Release/* -DestinationPath bncsutil_${{ github.ref_name }}_amd64_dll.zip
112112
Compress-Archive -Path include -DestinationPath "bncsutil_${{ github.ref_name }}_amd64_dll.zip" -Update
113113
114-
- uses: actions/upload-artifact@v4
114+
- uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7
115115
with:
116116
retention-days: 1
117117
overwrite: true
@@ -123,18 +123,18 @@ jobs:
123123
runs-on: windows-latest
124124

125125
steps:
126-
- uses: actions/checkout@v4
126+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
127127

128-
- uses: TheMrMilchmann/setup-msvc-dev@v3
128+
- uses: TheMrMilchmann/setup-msvc-dev@79dac248aac9d0059f86eae9d8b5bfab4e95e97c # v4
129129
with:
130130
arch: x86
131131

132132
- name: Install Conan
133133
id: conan
134-
uses: turtlebrowser/get-conan@main
134+
uses: turtlebrowser/get-conan@c171f295f3f507360ee018736a6608731aa2109d # v1.2
135135

136136
- name: Cache Conan
137-
uses: actions/cache@v3
137+
uses: actions/cache@668228422ae6a00e4ad889ee87cd7109ec5666a7 # v5
138138
with:
139139
key: conan-windows-x86-${{ hashFiles('conanfile.py') }}
140140
path: |
@@ -160,7 +160,7 @@ jobs:
160160
Compress-Archive -Path Release/* -DestinationPath bncsutil_${{ github.ref_name }}_x86_dll.zip
161161
Compress-Archive -Path include -DestinationPath "bncsutil_${{ github.ref_name }}_x86_dll.zip" -Update
162162
163-
- uses: actions/upload-artifact@v4
163+
- uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7
164164
with:
165165
retention-days: 1
166166
overwrite: true
@@ -174,27 +174,27 @@ jobs:
174174

175175
steps:
176176
- name: Download deb
177-
uses: actions/download-artifact@v4
177+
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
178178
with:
179179
name: libbncsutil-dev_${{ github.ref_name }}_amd64.deb
180180

181181
- name: Download rpm
182-
uses: actions/download-artifact@v4
182+
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
183183
with:
184184
name: libbncsutil-devel-${{ github.ref_name }}.x86_64.rpm
185185

186186
- name: Download dll amd64
187-
uses: actions/download-artifact@v4
187+
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
188188
with:
189189
name: bncsutil_${{ github.ref_name }}_amd64_dll.zip
190190

191191
- name: Download dll x86
192-
uses: actions/download-artifact@v4
192+
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
193193
with:
194194
name: bncsutil_${{ github.ref_name }}_x86_dll.zip
195195

196196
- name: Create GitHub Release
197-
uses: softprops/action-gh-release@v1
197+
uses: softprops/action-gh-release@153bb8e04406b158c6c84fc1615b65b24149a1fe # v2
198198
with:
199199
files: |
200200
libbncsutil-dev_${{ github.ref_name }}_amd64.deb

CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ set(HEADERS
2020
"src/bncsutil/file.h"
2121
"src/bncsutil/keytables.h"
2222
"src/bncsutil/libinfo.h"
23-
"src/bncsutil/ms_stdint.h"
2423
"src/bncsutil/mutil.h"
2524
"src/bncsutil/mutil_types.h"
2625
"src/bncsutil/nls.h"

src/bncsutil/cdkeydecoder.cpp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,8 @@ CDKeyDecoder::CDKeyDecoder(const char* cdKey, size_t keyLength) {
140140
cdkey = new char[keyLength + 1];
141141
initialized = 1;
142142
keyLen = keyLength;
143-
strcpy(cdkey, cdKey);
143+
memcpy(cdkey, cdKey, keyLength);
144+
cdkey[keyLength] = '\0';
144145

145146
switch (keyType) {
146147
case KEY_STARCRAFT:
@@ -421,12 +422,12 @@ int CDKeyDecoder::processWarCraft2Key() {
421422
cdkey[j] = c;
422423
if (c <= '7') {
423424
v = v2;
424-
c2 = ((char) (v & 0xFF)) & 7 ^ c;
425+
c2 = (((char) (v & 0xFF)) & 7) ^ c;
425426
v >>= 3;
426427
cdkey[j] = (char) c2;
427428
v2 = v;
428429
} else if (c < 'A') {
429-
cdkey[j] = ((char) j) & 1 ^ c;
430+
cdkey[j] = (((char) j) & 1) ^ c;
430431
}
431432
}
432433

@@ -526,14 +527,14 @@ void CDKeyDecoder::decodeKeyTable(int* keyTable) {
526527
/*
527528
ecx = (j & 7) << 2;
528529
ebp = (keyTable[0x3 - (j >> 3)] & (0xF << ecx)) >> ecx;
529-
varC = w3TranslateMap[ebp ^ w3TranslateMap[varC + i] + i];
530+
varC = w3TranslateMap[ebp ^ (w3TranslateMap[varC + i] + i)];
530531
*/
531532
ecx = (j & 7) << 2;
532533
//ebp = (keyTable[0x3 - (j >> 3)] & (0xF << ecx)) >> ecx;
533534
ebp = (keyTable[0x3 - (j >> 3)]);
534535
ebp &= (0xF << ecx);
535536
ebp = ebp >> ecx;
536-
varC = w3TranslateMap[ebp ^ w3TranslateMap[varC + i] + i];
537+
varC = w3TranslateMap[ebp ^ (w3TranslateMap[varC + i] + i)];
537538
}
538539
}
539540

@@ -544,13 +545,13 @@ void CDKeyDecoder::decodeKeyTable(int* keyTable) {
544545
ebp = (keyTable[0x3 - (j >> 3)]);
545546
ebp &= (0xF << ecx);
546547
ebp = ebp >> ecx;
547-
varC = w3TranslateMap[ebp ^ w3TranslateMap[varC + i] + i];
548+
varC = w3TranslateMap[ebp ^ (w3TranslateMap[varC + i] + i)];
548549
j--;
549550
}
550551

551552
j = 3 - var4;
552553
ebx = (w3TranslateMap[varC + i] & 0xF) << esi;
553-
keyTable[j] = (ebx | ~(0xF << esi) & ((int) keyTable[j]));
554+
keyTable[j] = (ebx | (~(0xF << esi) & ((int) keyTable[j])));
554555
} while ((i -= 16) >= 0);
555556

556557
// pass 2

src/bncsutil/checkrevision.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ MEXP(int) checkRevision(const char* formula, const char* files[], int numFiles,
219219
values[0] ^= checkrevision_seeds[mpqNumber];
220220

221221
for (int i = 0; i < numFiles; i++) {
222-
size_t file_len, remainder, rounded_size, buffer_size;
222+
size_t file_len, remainder, buffer_size;
223223

224224
f = file_open(files[i], FILE_READ);
225225
if (!f) {
@@ -230,7 +230,6 @@ MEXP(int) checkRevision(const char* formula, const char* files[], int numFiles,
230230

231231
file_len = file_size(f);
232232
remainder = file_len % 1024;
233-
rounded_size = file_len - remainder;
234233

235234
file_buffer = (uint8_t*) file_map(f, file_len, 0);
236235
if (!file_buffer) {
@@ -291,6 +290,7 @@ MEXP(int) checkRevision(const char* formula, const char* files[], int numFiles,
291290
break;
292291
case '/':
293292
// well, you never know
293+
if (values[ovs2[k]] == 0) return 0;
294294
values[ovd[k]] = values[ovs1[k]] / values[ovs2[k]];
295295
break;
296296
default:

src/bncsutil/file.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ file_t file_open(const char* filename, unsigned int mode)
6767

6868
try {
6969
data = new _file;
70-
} catch (std::bad_alloc) {
70+
} catch (const std::bad_alloc&) {
7171
//bncsutil_debug_message_a("Failed to allocate %u bytes to hold file structure.", sizeof(struct _file));
7272
CloseHandle(file);
7373
return (file_t) 0;
@@ -200,7 +200,7 @@ file_t file_open(const char* filename, const unsigned int mode_flags)
200200

201201
try {
202202
data = new _file;
203-
} catch (std::bad_alloc) {
203+
} catch (const std::bad_alloc&) {
204204
//bncsutil_debug_message_a("Failed to allocate %u bytes to hold file structure.", sizeof(struct _file));
205205
fclose(f);
206206
return (file_t) 0;

0 commit comments

Comments
 (0)