summaryrefslogtreecommitdiff
path: root/compat/clipped-write.c
diff options
context:
space:
mode:
Diffstat (limited to 'compat/clipped-write.c')
-rw-r--r--compat/clipped-write.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/compat/clipped-write.c b/compat/clipped-write.c
new file mode 100644
index 0000000..b8f98ff
--- /dev/null
+++ b/compat/clipped-write.c
@@ -0,0 +1,13 @@
+#include "../git-compat-util.h"
+#undef write
+
+/*
+ * Version of write that will write at most INT_MAX bytes.
+ * Workaround a xnu bug on Mac OS X
+ */
+ssize_t clipped_write(int fildes, const void *buf, size_t nbyte)
+{
+ if (nbyte > INT_MAX)
+ nbyte = INT_MAX;
+ return write(fildes, buf, nbyte);
+}