diff --git a/.github/workflows/test-makefile-build-macos-universal.yml b/.github/workflows/test-makefile-build-macos-universal.yml index 2a7198ef..36477bf4 100644 --- a/.github/workflows/test-makefile-build-macos-universal.yml +++ b/.github/workflows/test-makefile-build-macos-universal.yml @@ -4,9 +4,9 @@ on: workflow_dispatch: inputs: branch: - description: 'Branch to build from (default: OpenSSL_Pipeline_3.5.4_Upgrade_v2)' + description: 'Branch to build from (default: main)' required: false - default: 'OpenSSL_Pipeline_3.5.4_Upgrade_v2' + default: 'main' jobs: test-build-universal: @@ -17,7 +17,7 @@ jobs: - name: Checkout repository uses: actions/checkout@v4 with: - ref: ${{ github.event.inputs.branch || 'OpenSSL_Pipeline_3.5.4_Upgrade_v2' }} + ref: ${{ github.event.inputs.branch || 'main' }} - name: Verify macOS version and architecture run: | @@ -157,3 +157,4 @@ jobs: build/meshagent_macos-x86-64 build/meshagent_macos-arm-64 retention-days: 7 + diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a4548343..a388a465 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,11 +1,4 @@ name: MeshAgent Test -permissions: - contents: write - packages: write - actions: write - pull-requests: write - attestations: write - id-token: write on: pull_request: @@ -31,6 +24,8 @@ jobs: build_client: name: "Build C Client (${{ matrix.os }})" runs-on: ${{ matrix.os }} + permissions: + contents: read if: | (github.event_name == 'pull_request' && !github.event.pull_request.draft) defaults: @@ -86,4 +81,4 @@ jobs: run: | echo "Building MeshAgent for macOS ${{ matrix.os_arch }}" make macos ARCHID=${{ matrix.archid }} - shell: bash \ No newline at end of file + shell: bash diff --git a/meshcore/KVM/Windows/input.c b/meshcore/KVM/Windows/input.c index f9ffeb0e..e8ba28e3 100644 --- a/meshcore/KVM/Windows/input.c +++ b/meshcore/KVM/Windows/input.c @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ -#if defined(_LINKVM) +#if defined(_LINKVM) && defined(WIN32) #include #include @@ -611,3 +611,4 @@ int TouchAction2(char* data, int datalen, int scaling) } #endif + diff --git a/meshcore/KVM/Windows/tile.cpp b/meshcore/KVM/Windows/tile.cpp index 014625dc..1bf38838 100644 --- a/meshcore/KVM/Windows/tile.cpp +++ b/meshcore/KVM/Windows/tile.cpp @@ -89,7 +89,7 @@ int GetEncoderClsid(const WCHAR* format, CLSID* pClsid) for (unsigned int j = 0; j < num; ++j) { - if (wcsncmp(pImageCodecInfo[j].MimeType, format, size) == 0) + if (wcsncmp(pImageCodecInfo[j].MimeType, format, wcslen(format)) == 0) { *pClsid = pImageCodecInfo[j].Clsid; free(pImageCodecInfo); @@ -648,3 +648,4 @@ void set_tile_compression(int type, int level) } #endif + diff --git a/meshcore/wincrypto-dualmode.cpp b/meshcore/wincrypto-dualmode.cpp index 87a12b9b..048c264f 100644 --- a/meshcore/wincrypto-dualmode.cpp +++ b/meshcore/wincrypto-dualmode.cpp @@ -391,10 +391,15 @@ int __fastcall wincrypto_open(int newcert) if (hKeyNode != NULL) CryptDestroyKey(hKeyNode); #endif wincrypto_close(); + if (subjectEncoded != NULL) free(subjectEncoded); + if (pbPolicyInfo2 != NULL) free(pbPolicyInfo2); + if (pbBasicConstraints != NULL) free(pbBasicConstraints); return 1; end: if (subjectEncoded != NULL) free(subjectEncoded); + if (pbPolicyInfo2 != NULL) free(pbPolicyInfo2); + if (pbBasicConstraints != NULL) free(pbBasicConstraints); return 0; } diff --git a/microscript/ILibDuktape_CompressedStream.c b/microscript/ILibDuktape_CompressedStream.c index 5105bb75..21802d8f 100644 --- a/microscript/ILibDuktape_CompressedStream.c +++ b/microscript/ILibDuktape_CompressedStream.c @@ -122,6 +122,7 @@ void ILibDuktape_Compressor_End(ILibDuktape_DuplexStream *stream, void *user) char tmp[16384]; size_t avail; int res; + int errFlag = 0; cs->Z.avail_in = 0; cs->Z.next_in = (Bytef*)ILibScratchPad; @@ -131,6 +132,7 @@ void ILibDuktape_Compressor_End(ILibDuktape_DuplexStream *stream, void *user) cs->Z.next_out = (Bytef*)tmp; if ((res = deflate(&(cs->Z), Z_FINISH)) != Z_OK && res != Z_STREAM_END) { + errFlag = 1; break; } avail = sizeof(tmp) - cs->Z.avail_out; @@ -140,6 +142,15 @@ void ILibDuktape_Compressor_End(ILibDuktape_DuplexStream *stream, void *user) ILibDuktape_DuplexStream_WriteData(cs->ds, tmp, (int)avail); } } while (cs->Z.avail_out == 0); + if (errFlag != 0) + { + duk_push_heapptr(ctx, cs->object); // [stream] + duk_push_error_object(ctx, DUK_ERR_ERROR, "Compressor error: deflate() failed"); // [stream][error] + ILibDuktape_EventEmitter_SetupEmit(ctx, -2, "error"); // [stream][error][emit] + duk_swap(ctx, -1, -2); // [stream][emit][error] + duk_pcall_method(ctx, 1); // [stream][result] + duk_pop_2(ctx); // ... + } ILibDuktape_DuplexStream_WriteEnd(cs->ds); ignore_result(deflateEnd(&(cs->Z))); @@ -290,6 +301,7 @@ void ILibDuktape_deCompressor_End(ILibDuktape_DuplexStream *stream, void *user) cs->Z.avail_in = 0; cs->Z.next_in = (Bytef*)ILibScratchPad; int res; + int errFlag = 0; do { @@ -297,6 +309,7 @@ void ILibDuktape_deCompressor_End(ILibDuktape_DuplexStream *stream, void *user) cs->Z.next_out = (Bytef*)tmp; if ((res = inflate(&(cs->Z), Z_FINISH)) != Z_OK && res != Z_STREAM_END) { + errFlag = 1; break; } avail = sizeof(tmp) - cs->Z.avail_out; @@ -306,6 +319,15 @@ void ILibDuktape_deCompressor_End(ILibDuktape_DuplexStream *stream, void *user) ILibDuktape_DuplexStream_WriteData(cs->ds, tmp, (int)avail); } } while (cs->Z.avail_out == 0); + if (errFlag != 0) + { + duk_push_heapptr(ctx, cs->object); // [stream] + duk_push_error_object(ctx, DUK_ERR_ERROR, "Decompressor error: inflate() failed"); // [stream][error] + ILibDuktape_EventEmitter_SetupEmit(ctx, -2, "error"); // [stream][error][emit] + duk_swap(ctx, -1, -2); // [stream][emit][error] + duk_pcall_method(ctx, 1); // [stream][result] + duk_pop_2(ctx); // ... + } ILibDuktape_DuplexStream_WriteEnd(cs->ds); ignore_result(inflateEnd(&(cs->Z))); @@ -537,4 +559,4 @@ int ILibInflate(char *buffer, size_t bufferLen, char *decompressed, size_t *deco if (crc != 0 && crc != rescrc) { ret = 2; } return(ret); -} \ No newline at end of file +} diff --git a/microscript/ILibDuktape_Dgram.c b/microscript/ILibDuktape_Dgram.c index daab5bdb..bdb8610e 100644 --- a/microscript/ILibDuktape_Dgram.c +++ b/microscript/ILibDuktape_Dgram.c @@ -329,7 +329,7 @@ duk_ret_t ILibDuktape_DGram_send(duk_context *ctx) port = (unsigned short)duk_require_int(ctx, 3); for (i = 4; i < nargs; ++i) { - if (duk_is_string(ctx, i)) { ILibResolveEx((char*)duk_require_string(ctx, i), port, &local); } + if (duk_is_string(ctx, i)) { if (ILibResolveEx((char*)duk_require_string(ctx, i), port, &local) != 0) { local.sin6_family = AF_UNSPEC; } } if (duk_is_function(ctx, i)) { onSendOk = duk_require_heapptr(ctx, i); } } } @@ -338,7 +338,7 @@ duk_ret_t ILibDuktape_DGram_send(duk_context *ctx) port = (unsigned short)duk_require_int(ctx, 1); for (i = 2; i < nargs; ++i) { - if (duk_is_string(ctx, i)) { ILibResolveEx((char*)duk_require_string(ctx, i), port, &local); } + if (duk_is_string(ctx, i)) { if (ILibResolveEx((char*)duk_require_string(ctx, i), port, &local) != 0) { local.sin6_family = AF_UNSPEC; } } if (duk_is_function(ctx, i)) { onSendOk = duk_require_heapptr(ctx, i); } } } @@ -650,3 +650,4 @@ class dgram #endif + diff --git a/microstack/ILibAsyncServerSocket.c b/microstack/ILibAsyncServerSocket.c index f639b4b1..c4744dce 100644 --- a/microstack/ILibAsyncServerSocket.c +++ b/microstack/ILibAsyncServerSocket.c @@ -385,7 +385,17 @@ void ILibAsyncServerSocket_OnConnectSink(ILibAsyncSocket_SocketModule socketModu { struct ILibAsyncServerSocket_Data *data = (struct ILibAsyncServerSocket_Data*)user; if (data == NULL) return; - if (Connected == 0) { free(data); data = NULL; return; } // Connection Failed, clean up + if (Connected == 0) + { + // Connection Failed, clean up + if (ILibAsyncSocket_GetUser(socketModule) != NULL) + { + ILibAsyncSocket_SetUser(socketModule, NULL); + } + free(data); + data = NULL; + return; + } if (data->module->OnConnect != NULL) data->module->OnConnect(data->module, socketModule, &(data->user)); } // @@ -791,3 +801,4 @@ void ILibAsyncServerSocket_SSL_SetSink(ILibAsyncServerSocket_ServerModule AsyncS ((struct ILibAsyncServerSocketModule*)AsyncServerSocketModule)->OnSSLContext = handler; } #endif + diff --git a/microstack/nossl/sha224-256.c b/microstack/nossl/sha224-256.c index 977f8b69..23e0d409 100644 --- a/microstack/nossl/sha224-256.c +++ b/microstack/nossl/sha224-256.c @@ -90,10 +90,9 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. /* * add "length" to the length */ -static uint32_t addTemp; #define SHA224_256AddLength(context, length) \ - (addTemp = (context)->Length_Low, (context)->Corrupted = \ - (((context)->Length_Low += (length)) < addTemp) && \ + ((context)->Corrupted = \ + (((context)->Length_Low += (length)) < (length)) && \ (++(context)->Length_High == 0) ? 1 : 0) /* Local Function Prototypes */ @@ -634,3 +633,4 @@ SHA224_256ResultN(SHA256Context * context, return shaSuccess; } + diff --git a/modules/_agentNodeId.js b/modules/_agentNodeId.js index 93c52920..eaad42f7 100644 --- a/modules/_agentNodeId.js +++ b/modules/_agentNodeId.js @@ -138,6 +138,7 @@ function _meshName() function _resetNodeId() { + if (process.platform != 'win32') { return; } var name = _meshName(); require('win-registry').WriteKey(require('win-registry').HKEY.LocalMachine, 'Software\\Open Source\\' + name, 'ResetNodeId', 1); console.log('Resetting NodeID for: ' + name); diff --git a/modules/amt-lme.js b/modules/amt-lme.js index 31df141b..e25e16d4 100644 --- a/modules/amt-lme.js +++ b/modules/amt-lme.js @@ -150,7 +150,9 @@ function lme_heci(options) { console.log('Unhandled LME Command ' + cmd + ', ' + chunk.length + ' byte(s).'); break; case APF_SERVICE_REQUEST: + if (chunk.length < 5) { break; } var nameLen = chunk.readUInt32BE(1); + if (nameLen < 0 || (nameLen + 5) > chunk.length) { break; } var name = chunk.slice(5, nameLen + 5); //console.log("Service Request for: " + name); if (name == 'pfwd@amt.intel.com' || name == 'auth@amt.intel.com') { @@ -165,12 +167,16 @@ function lme_heci(options) { } break; case APF_GLOBAL_REQUEST: + if (chunk.length < 5) { break; } var nameLen = chunk.readUInt32BE(1); + if (nameLen < 0 || (nameLen + 5) > chunk.length) { break; } var name = chunk.slice(5, nameLen + 5).toString(); switch (name) { case 'tcpip-forward': + if (chunk.length < (nameLen + 10)) { break; } var len = chunk.readUInt32BE(nameLen + 6); + if (len < 0 || chunk.length < (nameLen + 14 + len)) { break; } var port = chunk.readUInt32BE(nameLen + 10 + len); //console.log("[" + chunk.length + "/" + len + "] APF_GLOBAL_REQUEST for: " + name + " on port " + port); if (this[name] == undefined) { this[name] = {}; } @@ -379,14 +385,18 @@ function lme_heci(options) { } break; case APF_CHANNEL_OPEN: + if (chunk.length < 5) { break; } var nameLen = chunk.readUInt32BE(1); + if (nameLen < 0 || chunk.length < (nameLen + 21)) { break; } var name = chunk.slice(5, nameLen + 5).toString(); var channelSender = chunk.readUInt32BE(nameLen + 5); var initialWindowSize = chunk.readUInt32BE(nameLen + 9); var hostToConnectLen = chunk.readUInt32BE(nameLen + 17); + if (hostToConnectLen < 0 || chunk.length < (nameLen + 29 + hostToConnectLen)) { break; } var hostToConnect = chunk.slice(nameLen + 21, nameLen + 21 + hostToConnectLen).toString(); var portToConnect = chunk.readUInt32BE(nameLen + 21 + hostToConnectLen); var originatorIpLen = chunk.readUInt32BE(nameLen + 25 + hostToConnectLen); + if (originatorIpLen < 0 || chunk.length < (nameLen + 33 + hostToConnectLen + originatorIpLen)) { break; } var originatorIp = chunk.slice(nameLen + 29 + hostToConnectLen, nameLen + 29 + hostToConnectLen + originatorIpLen).toString(); var originatorPort = chunk.readUInt32BE(nameLen + 29 + hostToConnectLen + originatorIpLen); //console.log('APF_CHANNEL_OPEN', name, channelSender, initialWindowSize, 'From: ' + originatorIp + ':' + originatorPort, 'To: ' + hostToConnect + ':' + portToConnect); diff --git a/modules/kvm-helper.js b/modules/kvm-helper.js index 20983051..c63d10a0 100644 --- a/modules/kvm-helper.js +++ b/modules/kvm-helper.js @@ -121,67 +121,55 @@ if (process.platform == 'linux') } + function waylandStatusForConf(confPath) + { + var child = require('child_process').execFile('/bin/sh', ['sh']); + child.stdout.str = ''; child.stdout.on('data', function (c) { this.str += c.toString(); }); + child.stdin.write('cat ' + confPath + " | grep WaylandEnable= | tr '\\n' '`' | awk -F'`' '"); + child.stdin.write('{'); + child.stdin.write(' wayland=1;'); + child.stdin.write(' for(n=1;n ' + tmpPath + '\n'); + child.stdin.write('mv ' + tmpPath + ' ' + confPath + '\n'); + child.stdin.write("\nexit\n"); + child.waitExit(); + } + function waylandStatus() { var wayland = true; if (require('fs').existsSync('/etc/gdm/custom.conf')) { - var child = require('child_process').execFile('/bin/sh', ['sh']); - child.stdout.str = ''; child.stdout.on('data', function (c) { this.str += c.toString(); }); - child.stdin.write("cat /etc/gdm/custom.conf | grep WaylandEnable= | tr '\\n' '`' | awk -F'`' '"); - child.stdin.write('{'); - child.stdin.write(' wayland=1;'); - child.stdin.write(' for(n=1;n /etc/gdm/custom_2.conf\n'); - child.stdin.write("mv /etc/gdm/custom_2.conf /etc/gdm/custom.conf\n"); - child.stdin.write("\nexit\n"); - child.waitExit(); + setWaylandForConf('/etc/gdm/custom.conf', 's/#WaylandEnable=false/WaylandEnable=false/g'); } if (require('fs').existsSync('/etc/gdm3/custom.conf')) { - var child = require('child_process').execFile('/bin/sh', ['sh']); - child.stdout.str = ''; child.stdout.on('data', function (c) { this.str += c.toString(); }); - child.stdin.write('sed "s/#WaylandEnable=false/WaylandEnable=false/g" /etc/gdm3/custom.conf > /etc/gdm3/custom_2.conf\n'); - child.stdin.write("mv /etc/gdm3/custom_2.conf /etc/gdm3/custom.conf\n"); - child.stdin.write("\nexit\n"); - child.waitExit(); + setWaylandForConf('/etc/gdm3/custom.conf', 's/#WaylandEnable=false/WaylandEnable=false/g'); } } } @@ -216,21 +194,11 @@ if (process.platform == 'linux') { if (require('fs').existsSync('/etc/gdm/custom.conf')) { - var child = require('child_process').execFile('/bin/sh', ['sh']); - child.stdout.str = ''; child.stdout.on('data', function (c) { this.str += c.toString(); }); - child.stdin.write('sed "s/WaylandEnable=false/#WaylandEnable=false/g" /etc/gdm/custom.conf > /etc/gdm/custom_2.conf\n'); - child.stdin.write("mv /etc/gdm/custom_2.conf /etc/gdm/custom.conf\n"); - child.stdin.write("\nexit\n"); - child.waitExit(); + setWaylandForConf('/etc/gdm/custom.conf', 's/WaylandEnable=false/#WaylandEnable=false/g'); } if (require('fs').existsSync('/etc/gdm3/custom.conf')) { - var child = require('child_process').execFile('/bin/sh', ['sh']); - child.stdout.str = ''; child.stdout.on('data', function (c) { this.str += c.toString(); }); - child.stdin.write('sed "s/WaylandEnable=false/#WaylandEnable=false/g" /etc/gdm3/custom.conf > /etc/gdm3/custom_2.conf\n'); - child.stdin.write("mv /etc/gdm3/custom_2.conf /etc/gdm3/custom.conf\n"); - child.stdin.write("\nexit\n"); - child.waitExit(); + setWaylandForConf('/etc/gdm3/custom.conf', 's/WaylandEnable=false/#WaylandEnable=false/g'); } } } @@ -262,4 +230,4 @@ else users: getUsers, allowed: allowedUIDs } -} \ No newline at end of file +} diff --git a/modules/smbios.js b/modules/smbios.js index 2391b8e9..ca73ae84 100644 --- a/modules/smbios.js +++ b/modules/smbios.js @@ -279,7 +279,7 @@ function SMBiosTables() retVal.storageRedirection = amt[6] ? true : false; retVal.serialOverLan = amt[7] ? true : false; retVal.kvm = amt[14] ? true : false; - if (data[131].peek() && data[131].peek().slice(52, 56).toString() == 'vPro') + if (data[131] && data[131].peek() && data[131].peek().slice(52, 56).toString() == 'vPro') { var settings = data[131].peek(); if (settings[0] & 0x04) { retVal.TXT = (settings[0] & 0x08) ? true : false; } @@ -300,7 +300,7 @@ function SMBiosTables() } if (!retVal.AMT) { - if (data[131].peek() && data[131].peek().slice(52, 56).toString() == 'vPro') + if (data[131] && data[131].peek() && data[131].peek().slice(52, 56).toString() == 'vPro') { var settings = data[131].peek(); if ((settings[20] & 0x08) == 0x08) { retVal.AMT = true; } @@ -356,4 +356,4 @@ function SMBiosTables() } } -module.exports = new SMBiosTables(); \ No newline at end of file +module.exports = new SMBiosTables(); diff --git a/modules/wget.js b/modules/wget.js index 96cc255f..5ea51954 100644 --- a/modules/wget.js +++ b/modules/wget.js @@ -81,7 +81,7 @@ function wget(remoteUri, localFilePath, wgetoptions) { if(imsg.statusCode != 200) { - this.promise._rej('Server responsed with Status Code: ' + imsg.statusCode); + this.promise._rej(new Error('Server responded with Status Code: ' + imsg.statusCode)); } else { diff --git a/modules/win-crypto.js b/modules/win-crypto.js index 8423f596..9ab4b4aa 100644 --- a/modules/win-crypto.js +++ b/modules/win-crypto.js @@ -193,7 +193,6 @@ function WinCrypto() if (delimiter == '') { delimiter = ', '; } } } - console.log('Certificate Options: ' + inStr); // Check Extensions if (options._keyRestrictions) @@ -285,10 +284,6 @@ function WinCrypto() expiration.toBuffer().writeUInt16LE(year, 0); var pCert = this._Crypt32.CertCreateSelfSignCertificate(0, blob, 0, keyProvider, cryptAlgorithm, 0, expiration, ext ? ext : 0); - if (pCert.Val == 0) { - console.log('Error Code = ' + this._Kernel32.GetLastError().Val); - } - console.log('pCert = ' + pCert.Val); var privateKey = this._marshal.CreatePointer(); var keyspec = this._marshal.CreateVariable(4); @@ -300,10 +295,6 @@ function WinCrypto() pCert.privateKey = privateKey.Deref(); pCert.privateKey.keySpec = keyspec.toBuffer().readUInt32LE(); pCert.privateKey.needFree = needFree.toBuffer().readUInt32LE(); - console.log('keyResult=' + keyResult.Val); - console.log('NeedFree=' + needFree.toBuffer().readUInt32LE()); - console.log('KeySpec=' + keyspec.toBuffer().readUInt32LE()); - var certInfo = pCert.Deref(this._marshal.PointerSize == 4 ? 12 : 24, this._marshal.PointerSize).Deref(this._marshal.PointerSize == 4 ? 112 : 208); var signatureAlgorithm = certInfo.Deref(this._marshal.PointerSize == 4 ? 12 : 24, this._marshal.PointerSize); @@ -317,7 +308,6 @@ function WinCrypto() pCert.publicKey.oid = keyAlgorithm.Deref().String; pCert.SubjectPublicKeyInfo = publicKeyInfo; pCert.Subject = certInfo.Deref(this._marshal.PointerSize == 4 ? 48 : 80, this._marshal.PointerSize == 4 ? 112 : 208); - console.log('PublicKey/OID: ' + pCert.publicKey.oid); } pCert.parent = this; pCert.signMessage = function signMessage(message, options) @@ -390,7 +380,6 @@ function WinCrypto() { var signerCert = this._marshal.CreatePointer(); var decoded = this._marshal.CreateVariable(decodedLength.toBuffer().readUInt32LE()); - console.log('Decoded Length = ' + decodedLength.toBuffer().readUInt32LE()); if (this._Crypt32.CryptVerifyMessageSignature(verifyParam, 0, signedMessage, message.length, decoded, decodedLength, 0).Val != 0) { @@ -410,7 +399,6 @@ function WinCrypto() }; this.loadCert = function loadCert(encodedCert, options) { - console.log('LoadCert: ' + options.encodingType, 'Length: ' + encodedCert.length); var pbCertEncoded = this._marshal.CreateVariable(encodedCert.length); encodedCert.copy(pbCertEncoded.toBuffer()); @@ -635,9 +623,7 @@ function WinCrypto() { // success var pbEncoded = this._marshal.CreateVariable(dwSize.toBuffer().readUInt32LE()); - console.log('KeySpec: ' + signingCert.privateKey.keySpec); - console.log(this._Crypt32.CryptSignAndEncodeCertificate(signingCert.privateKey, signingCert.privateKey.keySpec, X509_ASN_ENCODING, X509_CERT_TO_BE_SIGNED, certinfo, sig, 0, pbEncoded, dwSize).Val); - console.log('dwSize: ' + dwSize.toBuffer().readUInt32LE()); + this._Crypt32.CryptSignAndEncodeCertificate(signingCert.privateKey, signingCert.privateKey.keySpec, X509_ASN_ENCODING, X509_CERT_TO_BE_SIGNED, certinfo, sig, 0, pbEncoded, dwSize); pbEncoded._size = dwSize.toBuffer().readUInt32LE(); return (pbEncoded); } @@ -664,9 +650,7 @@ function WinCrypto() { // success var pbEncoded = this._marshal.CreateVariable(dwSize.toBuffer().readUInt32LE()); - console.log('KeySpec: ' + signingCert.privateKey.keySpec); - console.log(this._Crypt32.CryptSignAndEncodeCertificate(signingCert.privateKey, signingCert.privateKey.keySpec, X509_ASN_ENCODING, X509_CERT_REQUEST_TO_BE_SIGNED, certRequestInfo, sig, 0, pbEncoded, dwSize).Val); - console.log('dwSize: ' + dwSize.toBuffer().readUInt32LE()); + this._Crypt32.CryptSignAndEncodeCertificate(signingCert.privateKey, signingCert.privateKey.keySpec, X509_ASN_ENCODING, X509_CERT_REQUEST_TO_BE_SIGNED, certRequestInfo, sig, 0, pbEncoded, dwSize); pbEncoded._size = dwSize.toBuffer().readUInt32LE(); return (pbEncoded); } @@ -772,4 +756,4 @@ module.exports = new WinCrypto(); //console.log(result.data, result.signingCertificate.publicKeyHash, result.signingCertificate.fingerprint); //var decoded = cng.verifyMessage(msg, { encodingType: PKCS_7_ASN_ENCODING }); -//console.log(decoded.toString()); \ No newline at end of file +//console.log(decoded.toString()); diff --git a/modules/win-securitycenter.js b/modules/win-securitycenter.js index ccb52f57..4cb8b4ce 100644 --- a/modules/win-securitycenter.js +++ b/modules/win-securitycenter.js @@ -101,7 +101,7 @@ if (process.platform == 'win32' && seccenter != null) j.on('~', function () { // Unregister our event handler - if (seccenter.WscUnRegisterChanges(this._H).Val == 0) { } + if (seccenter.WscUnRegisterChanges(this._H).Val == 0) { } else { console.log('win-securitycenter: WscUnRegisterChanges failed'); } }); if (seccenter.WscRegisterForChanges(0, j._H, j._EV, require('_GenericMarshal').ObjectToPtr(j)).Val == 0) // Setup event handling @@ -113,4 +113,4 @@ if (process.platform == 'win32' && seccenter != null) else { throw ('win-securitycenter not supported on this platform'); -} \ No newline at end of file +} diff --git a/openssl/include/openssl/byteorder.h b/openssl/include/openssl/byteorder.h index 3c8f34b2..0032c685 100644 --- a/openssl/include/openssl/byteorder.h +++ b/openssl/include/openssl/byteorder.h @@ -179,7 +179,7 @@ OPENSSL_store_u64_le(unsigned char *out, uint64_t val) static ossl_inline ossl_unused unsigned char * OPENSSL_store_u64_be(unsigned char *out, uint64_t val) { -# ifdef OSSL_HTOLE64 +# ifdef OSSL_HTOBE64 uint64_t t = OSSL_HTOBE64(val); memcpy(out, (unsigned char *)&t, 8); @@ -218,7 +218,7 @@ OPENSSL_load_u16_le(uint16_t *val, const unsigned char *in) static ossl_inline ossl_unused const unsigned char * OPENSSL_load_u16_be(uint16_t *val, const unsigned char *in) { -# ifdef OSSL_LE16TOH +# ifdef OSSL_BE16TOH uint16_t t; memcpy((unsigned char *)&t, in, 2); @@ -256,7 +256,7 @@ OPENSSL_load_u32_le(uint32_t *val, const unsigned char *in) static ossl_inline ossl_unused const unsigned char * OPENSSL_load_u32_be(uint32_t *val, const unsigned char *in) { -# ifdef OSSL_LE32TOH +# ifdef OSSL_BE32TOH uint32_t t; memcpy((unsigned char *)&t, in, 4); @@ -301,7 +301,7 @@ OPENSSL_load_u64_le(uint64_t *val, const unsigned char *in) static ossl_inline ossl_unused const unsigned char * OPENSSL_load_u64_be(uint64_t *val, const unsigned char *in) { -# ifdef OSSL_LE64TOH +# ifdef OSSL_BE64TOH uint64_t t; memcpy((unsigned char *)&t, in, 8); diff --git a/samples/snippets/pwdtest.js b/samples/snippets/pwdtest.js index 80d4dfcb..5e615a4c 100644 --- a/samples/snippets/pwdtest.js +++ b/samples/snippets/pwdtest.js @@ -32,6 +32,7 @@ console.canonical = false; // This takes the console out of canonical mode, whi process.stdin.chars = ''; // This is where we will store the result process.stdin.on('data', function (c) { + var i; switch(c[0]) { case 127: // Linux Backspace @@ -70,4 +71,4 @@ process.on('exit', function () // making it difficult for the user to know whats going on when trying to interact with the console. console.echo = true; console.canonical = true; -}); \ No newline at end of file +}); diff --git a/scripts/generate_module_string.js b/scripts/generate_module_string.js index 459ecdfc..1c067426 100755 --- a/scripts/generate_module_string.js +++ b/scripts/generate_module_string.js @@ -3,6 +3,10 @@ const fs = require('fs'); const zlib = require('zlib'); +function escapeRegExp(str) { + return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); +} + function embedModule(moduleName) { const filePath = `modules_expanded/${moduleName}.js`; const cFilePath = 'microscript/ILibDuktape_Polyfills.c'; @@ -69,13 +73,14 @@ function embedModule(moduleName) { } // Проверяем, не встроен ли уже этот модуль - const existingModulePattern = new RegExp(`addCompressedModule\\('${moduleName}'`); + const escapedModuleName = escapeRegExp(moduleName); + const existingModulePattern = new RegExp(`addCompressedModule\\('${escapedModuleName}'(?=[',])`); const bodySection = cFileContent.substring(beginIndex, endIndex); if (existingModulePattern.test(bodySection)) { console.log(`- Module '${moduleName}' is already embedded, replacing...`); // Удаляем старую версию модуля - const modulePattern = new RegExp(`\\s*duk_peval_string_noresult\\(ctx, "addCompressedModule\\('${moduleName}'[^;]+;\\);\\s*`, 'g'); + const modulePattern = new RegExp(`\\s*duk_peval_string_noresult\\(ctx, "addCompressedModule\\('${escapedModuleName}'(?=[',])[^;]+;\\);\\s*`, 'g'); const cleanedContent = cFileContent.replace(modulePattern, ''); // Создаем новое содержимое @@ -110,3 +115,4 @@ console.log('MeshAgent Module Embedder'); console.log('='.repeat(50)); embedModule(moduleName); +