mirror of
https://gitlab.freedesktop.org/libbsd/libbsd.git
synced 2025-10-15 15:16:53 +02:00
Fix strnvis() and strnunvis() NetBSD ABI break
The NetBSD implementations have different prototypes to the ones coming from OpenBSD, which will break builds, and have caused segfaults at run-time. We provide now both interfaces with different prototypes as different version nodes allow selecting them at compile-time, defaulting for now to the OpenBSD one to avoid build-time breakage, while emitting a compile-time warning. Later on, in 0.10.0, we will be switching the compile-time default to the NetBSD version. Ref: http://gnats.netbsd.org/44977 Fixes: https://bugs.debian.org/899282
This commit is contained in:
29
src/unvis.c
29
src/unvis.c
@@ -37,7 +37,10 @@
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
#include <errno.h>
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wcpp"
|
||||
#include <vis.h>
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
#ifdef __weak_alias
|
||||
__weak_alias(strnunvisx,_strnunvisx)
|
||||
@@ -543,8 +546,30 @@ strunvis(char *dst, const char *src)
|
||||
return strnunvisx(dst, (size_t)~0, src, 0);
|
||||
}
|
||||
|
||||
int
|
||||
strnunvis(char *dst, size_t dlen, const char *src)
|
||||
/*
|
||||
* NetBSD added an strnvis and unfortunately made it incompatible with the
|
||||
* existing one in OpenBSD and Freedesktop's libbsd (the former having existed
|
||||
* for over ten years). Despite this incompatibility being reported during
|
||||
* development (see http://gnats.netbsd.org/44977) they still shipped it.
|
||||
* Even more unfortunately FreeBSD and later MacOS picked up this incompatible
|
||||
* implementation.
|
||||
*
|
||||
* Provide both implementations and default for now on the historical one to
|
||||
* avoid breakage, we will switch to the NetBSD one in libbsd 0.10.0 or so.
|
||||
*
|
||||
* OpenBSD, 2001: strnunvis(char *dst, const char *src, size_t dlen);
|
||||
* NetBSD: 2012, strnunvis(char *dst, size_t dlen, const char *src);
|
||||
*/
|
||||
ssize_t
|
||||
strnunvis_openbsd(char *dst, const char *src, size_t dlen)
|
||||
{
|
||||
return strnunvisx(dst, dlen, src, 0);
|
||||
}
|
||||
__asm__(".symver strnunvis_openbsd,strnunvis@@LIBBSD_0.2");
|
||||
|
||||
int
|
||||
strnunvis_netbsd(char *dst, size_t dlen, const char *src)
|
||||
{
|
||||
return strnunvisx(dst, dlen, src, 0);
|
||||
}
|
||||
__asm__(".symver strnunvis_netbsd,strnunvis@LIBBSD_0.9.1");
|
||||
|
Reference in New Issue
Block a user