Source: ifhp
Followup-For: Bug #1128549
X-Debbugs-Cc: [email protected]
User: [email protected]
Usertags: origin-ubuntu stonking ubuntu-patch
Control: tags -1 patch ftbfs

Hi,

The attached patch fixes the build with glibc 2.43: strchr, strrchr,
strpbrk and strstr now return const char * when passed a const char *,
so src/safestrutil.c needs explicit casts in the wrappers declared to
return char *. It keeps the existing API.

Tested in Ubuntu with glibc 2.44 (amd64), where the package builds
again with it. Ubuntu bug:
https://bugs.launchpad.net/ubuntu/+source/ifhp/+bug/2170781

Thanks,
Sebastien Bacher


-- System Information:
Debian Release: forky/sid
  APT prefers resolute-updates
  APT policy: (500, 'resolute-updates'), (500, 'resolute-security'), (500, 
'resolute'), (100, 'resolute-backports')
Architecture: amd64 (x86_64)

Kernel: Linux 7.0.0-38-generic (SMP w/16 CPU threads; PREEMPT)
Kernel taint flags: TAINT_PROPRIETARY_MODULE, TAINT_WARN, TAINT_OOT_MODULE
Locale: LANG=fr_FR.UTF-8, LC_CTYPE=fr_FR.UTF-8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled
Description: Fix build with glibc 2.43 (ISO C23 const-preserving string 
functions)
 With glibc 2.43, strchr, strrchr, strpbrk and strstr return a const char *
 when passed a const char *, so returning their result from functions
 declared to return char * fails with -Werror=discarded-qualifiers.
 Cast explicitly, keeping the existing API.
Author: Sebastien Bacher <[email protected]>
Bug-Debian: https://bugs.debian.org/1128549
Forwarded: no
Last-Update: 2026-10-14
Index: ifhp-3.5.20+dfsg/src/safestrutil.c
===================================================================
--- ifhp-3.5.20+dfsg.orig/src/safestrutil.c
+++ ifhp-3.5.20+dfsg/src/safestrutil.c
@@ -80,7 +80,7 @@ int safestrncmp( const char *s1, const c
 /* perform safe strchr, even with null pointers */
 char *safestrchr( const char *s1, int c )
 {
-       if( s1 ) return( strchr( s1, c ) );
+       if( s1 ) return( (char *)strchr( s1, c ) );
        return( 0 );
 }
 
@@ -88,7 +88,7 @@ char *safestrchr( const char *s1, int c
 /* perform safe strrchr, even with null pointers */
 char *safestrrchr( const char *s1, int c )
 {
-       if( s1 ) return( strrchr( s1, c ) );
+       if( s1 ) return( (char *)strrchr( s1, c ) );
        return( 0 );
 }
 
@@ -96,7 +96,7 @@ char *safestrrchr( const char *s1, int c
 /* perform safe strchr, even with null pointers */
 char *safestrpbrk( const char *s1, const char *s2 )
 {
-       if( s1 && s2 ) return( strpbrk( s1, s2 ) );
+       if( s1 && s2 ) return( (char *)strpbrk( s1, s2 ) );
        return( 0 );
 }
 
@@ -104,7 +104,7 @@ char *safestrpbrk( const char *s1, const
 /* perform safe strstr, even with null pointers */
 char *safestrstr( const char *s1, const char *s2 )
 {
-       if( s1 && s2 ) return( strstr( s1, s2 ) );
+       if( s1 && s2 ) return( (char *)strstr( s1, s2 ) );
        return( 0 );
 }
 

Reply via email to