Loading...
--- Libc/Libc-763.13/stdio/FreeBSD/fputs.c
+++ Libc/Libc-1669.40.2/stdio/FreeBSD/fputs.c
@@ -43,19 +43,27 @@
#include "fvwrite.h"
#include "libc_private.h"
#include "local.h"
+#include "libc_hooks_impl.h"
+
+// 3340719: __puts_null__ is used if string is NULL. Defined in puts.c
+extern char const __puts_null__[];
/*
* Write the given string to the given file.
*/
int
-fputs(s, fp)
- const char * __restrict s;
- FILE * __restrict fp;
+fputs(const char * __restrict s, FILE * __restrict fp)
{
int retval;
struct __suio uio;
struct __siov iov;
+ libc_hooks_will_read_cstring(s);
+ libc_hooks_will_write(fp, sizeof(*fp));
+
+ // 3340719: __puts_null__ is used if s is NULL
+ if(s == NULL)
+ s = __puts_null__;
iov.iov_base = (void *)s;
iov.iov_len = uio.uio_resid = strlen(s);
uio.uio_iov = &iov;
@@ -64,5 +72,9 @@
ORIENT(fp, -1);
retval = __sfvwrite(fp, &uio);
FUNLOCKFILE(fp);
+#if __DARWIN_UNIX03
+ if (retval == 0)
+ return iov.iov_len;
+#endif /* __DARWIN_UNIX03 */
return (retval);
}