diff options
| author | Christoph Berg <myon@debian.org> | 2026-06-22 12:03:55 +0200 |
|---|---|---|
| committer | Christoph Berg <myon@debian.org> | 2026-06-22 12:03:55 +0200 |
| commit | de18fc13175a5bf0e2b48a042d2fc06e87c88d24 (patch) | |
| tree | f517074cd603d30eb7ba7e2122d38051e4c1439c /map65/getdev.cpp | |
| parent | b76e8361909e47f0937d4a64a5a4cb5939f51eb7 (diff) | |
| parent | d83a420f0517d7fc47aeb288a6a0cf4891784fcc (diff) | |
Update upstream source from tag 'upstream/3.0.2+dfsg'
Update to upstream version '3.0.2+dfsg'
with Debian dir 90381fe7be9f5ea84d9b16c9cccf200a3fbe138b
Diffstat (limited to 'map65/getdev.cpp')
| -rw-r--r-- | map65/getdev.cpp | 56 |
1 files changed, 41 insertions, 15 deletions
diff --git a/map65/getdev.cpp b/map65/getdev.cpp index 45addfa0..b3e55335 100644 --- a/map65/getdev.cpp +++ b/map65/getdev.cpp @@ -51,10 +51,34 @@ int pa_get_device_info (int n, minInputChannels=0; if(n >= Pa_GetDeviceCount() ) return -1; deviceInfo = Pa_GetDeviceInfo(n); - if (deviceInfo->maxInputChannels==0) return -1; - sprintf((char*)(pa_device_name),"%s",deviceInfo->name); - sprintf((char*)(pa_device_hostapi),"%s", - Pa_GetHostApiInfo( deviceInfo->hostApi )->name); + + // CRITICAL SAFETY CHECK: + if (!deviceInfo) { + qDebug() << "Skipping device index" << n << "because it returned a NULL pointer."; + return -1; + } + + if (deviceInfo->maxInputChannels == 0) return -1; + + // CRITICAL SAFETY CHECK: Validate the Host API info + const PaHostApiInfo* apiInfo = Pa_GetHostApiInfo(deviceInfo->hostApi); + if (!apiInfo) { + qDebug() << "Skipping device" << deviceInfo->name << "because its Host API is invalid."; + return -1; + } + + snprintf((char*)pa_device_name, + 128, + "%.127s", + deviceInfo->name); + + // Change this: + // snprintf((char*)pa_device_hostapi, 128, "%.127s", Pa_GetHostApiInfo(deviceInfo->hostApi)->name); + + // To this safe version: + snprintf((char*)pa_device_hostapi, 128, "%.127s", apiInfo->name); + + speed_warning=0; // bypass bug in Juli@ ASIO driver: @@ -83,14 +107,15 @@ int pa_get_device_info (int n, // ************************************************************************ //filter for portaudio Windows hostapi's with non experts. //only allow ASIO or WASAPI or WDM-KS - i = strncmp(Pa_GetHostApiInfo(deviceInfo->hostApi)->name, "ASIO", 4); - if (i==0 ) goto end_filter_hostapi; - i = strncmp(Pa_GetHostApiInfo(deviceInfo->hostApi)->name, - "Windows WASAPI", 14); - if (i==0 ) goto end_filter_hostapi; - i = strncmp(Pa_GetHostApiInfo(deviceInfo->hostApi)->name, - "Windows WDM-KS", 14); - if (i==0 ) goto end_filter_hostapi; +i = strncmp(apiInfo->name, "ASIO", 4); +if (i==0 ) goto end_filter_hostapi; + +i = strncmp(apiInfo->name, "Windows WASAPI", 14); +if (i==0 ) goto end_filter_hostapi; + +i = strncmp(apiInfo->name, "Windows WDM-KS", 14); +if (i==0 ) goto end_filter_hostapi; + speed_warning=1; end_filter_hostapi:; @@ -187,7 +212,7 @@ void paInputDevice(int id, char* hostAPI_DeviceName, int* minChan, int pa_device_min_channels; char p2[256]; char *p,*p1; - static int iret, valid_dev_cnt; + static int iret; iret=pa_get_device_info (id, &pa_device_name, @@ -200,7 +225,6 @@ void paInputDevice(int id, char* hostAPI_DeviceName, int* minChan, &pa_device_min_channels); if (iret >= 0 ) { - valid_dev_cnt++; p1=(char*)""; p=strstr(pa_device_hostapi,"MME"); @@ -214,7 +238,9 @@ void paInputDevice(int id, char* hostAPI_DeviceName, int* minChan, p=strstr(pa_device_hostapi,"WDM-KS"); if(p!=NULL) p1=(char*)"WDM-KS"; - sprintf(p2,"%-8s %-39s",p1,pa_device_name); + snprintf(p2, sizeof(p2), + "%-8s %-39.39s", + p1, pa_device_name); for(i=0; i<50; i++) { hostAPI_DeviceName[i]=p2[i]; if(p2[i]==0) break; |
