Skip to content
Merged
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
21 changes: 8 additions & 13 deletions microscript/ILibDuktape_ScriptContainer.c
Original file line number Diff line number Diff line change
Expand Up @@ -2506,24 +2506,19 @@
}\
catch(zz)\
{}\
/* OpenFrame: OS name from the registry, not WMI - the WMI query blocks the microstack thread until the 10min x2 watchdog kills the agent when WmiPrvSE is starved; the build-number check corrects the stale Win11 ProductName. */\
var build = '';\
try { build = require('win-registry').QueryKey(require('win-registry').HKEY.LocalMachine, 'SOFTWARE\\\\MICROSOFT\\\\WINDOWS NT\\\\CurrentVersion', 'CurrentBuild'); } catch(zz) {}\
try\
{\
ret = require('win-wmi').query('ROOT\\\\CIMV2', \"SELECT * FROM Win32_OperatingSystem\", ['Caption','BuildNumber']);\
ret = ret[0].Caption + ' - ' + friendly + ret[0].BuildNumber;\
ret = require('win-registry').QueryKey(require('win-registry').HKEY.LocalMachine, 'SOFTWARE\\\\MICROSOFT\\\\WINDOWS NT\\\\CurrentVersion', 'ProductName');\
if (parseInt(build) >= 22000 && ret.indexOf('Windows 10') == 0) { ret = ret.replace('Windows 10', 'Windows 11'); }\
ret = ret + ' - ' + friendly + build;\
}\
catch(zz)\
catch(zzz)\
{\
try\
{\
ret = require('win-registry').QueryKey(require('win-registry').HKEY.LocalMachine, 'SOFTWARE\\\\MICROSOFT\\\\WINDOWS NT\\\\CurrentVersion', 'ProductName');\
ret = ret + ' - ' + friendly + require('win-registry').QueryKey(require('win-registry').HKEY.LocalMachine, 'SOFTWARE\\\\MICROSOFT\\\\WINDOWS NT\\\\CurrentVersion', 'CurrentBuild');\
}\
catch(zzz)\
{\
ret = 'Windows (UNKNOWN) - ' + friendly;\
}\
ret += (' [WMI ERROR] ');\
ret = 'Windows (UNKNOWN) - ' + friendly + build;\
}\

Check warning on line 2521 in microscript/ILibDuktape_ScriptContainer.c

View workflow job for this annotation

GitHub Actions / Flamingo Code Review

Windows 11 rename check silently no-ops when the registry read for 'build' fails

Windows 11 rename check silently no-ops when the registry read for 'build' fails If the first try block (reading `CurrentBuild`) throws and is swallowed by `catch(zz) {}`, `build` remains the empty string `''`. Then `parseInt(build)` evaluates to `NaN`, and `NaN >= 22000` is `false`, so the Windows 11 rename never triggers even though that's an edge case that should perhaps be logged or handled distinctly from the case where the build number is legitimately below 22000. This is a silent-failure path: previously the code fell back to a WMI query and appended `[WMI ERROR]` to make failures visible; now a registry read failure for `CurrentBuild` produces a plausible-looking but potentially wrong OS name (e.g. 'Windows 10' when the machine actually is Windows 11) with no diagnostic trace at all, since 'build' is simply appended as an empty string with no error marker.
Comment thread
mikhailm-coder marked this conversation as resolved.
break;\
case 'linux':\
lines = child.stdout.str.split('\\n');\
Expand Down
Loading