Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <0e96cffef26b0a5b689e6d316211829f6ed1a1cf.camel@posteo.net>
Date: Fri, 31 Mar 2023 00:35:36 +0000
From: John Scott <jscott@...teo.net>
To: musl@...ts.openwall.com
Subject: [PATCH] Expose the fopencookie() data types more generally

Hi,

We're allowed to expose these data types in POSIX-conforming applications since they're implementation-reserved, and I think it's a good idea. My use case is that I want to check for fopencookie() via dlsym() without defining _GNU_SOURCE, and having the definition of cookie_io_functions_t would be helpful for its usage.

You may pull the signed commit from https://git.sr.ht/~jscott/musl-libc or use the following patch

From f5f6db0d02db40dde067a3ad0a7fbd74f6019dd4 Mon Sep 17 00:00:00 2001
From: John Scott <jscott@...teo.net>
Date: Thu, 30 Mar 2023 20:26:13 -0400
Subject: [PATCH] Expose the fopencookie() data types more generally

These data types end in _t and so can be exposed even when strict POSIX conformance is sought. This might be useful for an application that doesn't want other side effects of defining _GNU_SOURCE, but which still wants to use fopencookie().
---
 include/stdio.h | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/include/stdio.h b/include/stdio.h
index cb858618..a5206316 100644
--- a/include/stdio.h
+++ b/include/stdio.h
@@ -189,7 +189,11 @@ int vasprintf(char **, const char *, __isoc_va_list);
 #ifdef _GNU_SOURCE
 char *fgets_unlocked(char *, int, FILE *);
 int fputs_unlocked(const char *, FILE *);
+#endif
 
+#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \
+ || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \
+ || defined(_BSD_SOURCE)
 typedef ssize_t (cookie_read_function_t)(void *, char *, size_t);
 typedef ssize_t (cookie_write_function_t)(void *, const char *, size_t);
 typedef int (cookie_seek_function_t)(void *, off_t *, int);
@@ -201,7 +205,9 @@ typedef struct _IO_cookie_io_functions_t {
 	cookie_seek_function_t *seek;
 	cookie_close_function_t *close;
 } cookie_io_functions_t;
+#endif
 
+#ifdef _GNU_SOURCE
 FILE *fopencookie(void *, const char *, cookie_io_functions_t);
 #endif
 
-- 
2.35.1


Download attachment "signature.asc" of type "application/pgp-signature" (253 bytes)

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.