Description: Fix FTBFS caused by const-correct (C23) strstr() in glibc >= 2.43
 Screen() video capture parameter handling truncates the caller provided
 parameter string in place by writing a NUL byte at the position returned by
 strstr(). With C23 / glibc 2.43 the const-generic strstr() returns a
 "const char *" when the haystack is const-qualified, so that write is
 rejected at compile time ("assignment of read-only location"). Make the
 intended write explicit by casting the strstr() result to "char *".
 .
 Keeping the original in-place truncation preserves the previous behaviour.
Author: tangxiaofeng <tangxiaofeng@kylinos.cn>
Origin: vendor
Forwarded: not-needed
Last-Update: 2026-09-21
---
--- psychtoolbox-3-3.0.19.14.dfsg1.orig/PsychSourceGL/Source/Common/Screen/PsychVideoCaptureSupportGStreamer.c
+++ psychtoolbox-3-3.0.19.14.dfsg1/PsychSourceGL/Source/Common/Screen/PsychVideoCaptureSupportGStreamer.c
@@ -5178,7 +5178,10 @@ double PsychGSVideoCaptureSetParameter(i
 
         // Can't reassign new codec without reopening the device:
         if (strstr(pname, ":CodecType")) {
-            *(strstr(pname, ":CodecType")) = 0;
+            // NB: Cast the strstr() result to writable memory: since C23 / glibc-2.43 the
+            // const-generic strstr() returns a const char* for a const haystack, and the
+            // direct assignment below would fail to compile ("assignment of read-only location").
+            *((char *) strstr(pname, ":CodecType")) = 0;
             if (PsychPrefStateGet_Verbosity() > 1) {
                 printf("PTB-WARNING: Tried to change recording codec on device %i, but this isn't possible without reopening the device. Ignored.\n", capturehandle);
             }
--- psychtoolbox-3-3.0.19.14.dfsg1.orig/PsychSourceGL/Source/Common/Screen/PsychVideoCaptureSupportLibDC1394.c
+++ psychtoolbox-3-3.0.19.14.dfsg1/PsychSourceGL/Source/Common/Screen/PsychVideoCaptureSupportLibDC1394.c
@@ -2922,7 +2922,10 @@ double PsychDCVideoCaptureSetParameter(i
 
         // Can't reassign new codec without reopening the device:
         if (strstr(pname, ":CodecType")) {
-            *(strstr(pname, ":CodecType")) = 0;
+            // NB: Cast the strstr() result to writable memory: since C23 / glibc-2.43 the
+            // const-generic strstr() returns a const char* for a const haystack, and the
+            // direct assignment below would fail to compile ("assignment of read-only location").
+            *((char *) strstr(pname, ":CodecType")) = 0;
             if (PsychPrefStateGet_Verbosity() > 1) {
                 printf("PTB-WARNING: Tried to change recording codec on device %i, but this isn't possible without reopening the device. Ignored.\n", capturehandle);
             }
@@ -2930,7 +2933,10 @@ double PsychDCVideoCaptureSetParameter(i
 
         // Can't reassign new codec without reopening the device:
         if (strstr(pname, ":CodecSettings=")) {
-            *(strstr(pname, ":CodecSettings=")) = 0;
+            // NB: Cast the strstr() result to writable memory: since C23 / glibc-2.43 the
+            // const-generic strstr() returns a const char* for a const haystack, and the
+            // direct assignment below would fail to compile ("assignment of read-only location").
+            *((char *) strstr(pname, ":CodecSettings=")) = 0;
             if (PsychPrefStateGet_Verbosity() > 1) {
                 printf("PTB-WARNING: Tried to change recording codec settings on device %i, but this isn't possible without reopening the device. Ignored.\n", capturehandle);
             }
