Skip to content

Commit 44bcf1a

Browse files
committed
fix a possible buffer overflow and division by 0
1 parent cd737b4 commit 44bcf1a

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

src/bncsutil/cdkeydecoder.cpp

Lines changed: 2 additions & 1 deletion
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:

src/bncsutil/checkrevision.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,7 @@ MEXP(int) checkRevision(const char* formula, const char* files[], int numFiles,
291291
break;
292292
case '/':
293293
// well, you never know
294+
if (values[ovs2[k]] == 0) return 0;
294295
values[ovd[k]] = values[ovs1[k]] / values[ovs2[k]];
295296
break;
296297
default:

0 commit comments

Comments
 (0)