Skip to content

[P2] get_device_settings ignores its device_type override #244

Description

@drebbe-intrepid

Bug

device_type_override is parsed and used to skip icsneoGetDeviceSettingsType, but its value is never assigned to SDeviceSettings.DeviceSettingType. The subsequent DLL call receives the zero-initialized type instead of the requested override.

Reviewed commit: 45167e09de6b886cd451a4245f842c8221349711 (current master on 2026-09-15).
Source: src/methods.cpp:2192

Reproduction

This reproducer uses a hardware-free DLL. Save this as mock.c:

#define API __declspec(dllexport)
typedef unsigned long long size_t;
static int received;
API int icsneoGetDeviceSettings(void* h, int* settings, int size, int vnet) { received = *settings; return 1; }
API int review_received(void) { return received; }

Build with LLVM on Windows x64:

clang-cl /nologo /c /GS- /Zl mock.c /Fomock.obj
lld-link /dll /noentry /nodefaultlib /out:mock.dll mock.obj

Then run:

import ics
import ctypes
from pathlib import Path
ics.override_library_name(str(Path('mock.dll').resolve()))
d = ics.PyNeoDeviceEx()
d._auto_handle_close = False
result = ics.get_device_settings(d, ics.DeviceFire3SettingsType)
dll = ctypes.CDLL(str(Path('mock.dll').resolve()))
print('requested', ics.DeviceFire3SettingsType, 'received', dll.review_received(), 'returned', result.DeviceSettingType)

Observed / expected

requested 36 received 0 returned 0. Expected the requested type (36) to reach the DLL. The override is explicitly documented in include/methods.h. This can request the wrong settings layout or fail the native request.

Suggested fix and regression coverage

Assign the supplied override to *setting_type when it is not -1, with appropriate enum/range validation. Test both native type discovery and explicit overrides through a mock DLL.

Validation environment

Windows x64, CPython 3.14.5, extension rebuilt from the commit above. Hardware-dependent entry points below were exercised with a mock DLL, not a connected device. The existing 30 tests pass despite these findings.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions