diff options
author | Marco Trevisan <mail@3v1n0.net> | 2023-01-17 14:28:08 +0000 |
---|---|---|
committer | Marco Trevisan <mail@3v1n0.net> | 2023-01-17 14:28:08 +0000 |
commit | 78925535f98977bfb9ea5d03f1994c820ac439f3 (patch) | |
tree | ccf816018a3ba1c2655bc14f66e01ce78ea2701e | |
parent | 40233516bc2df49a1e540ab477ac0449320388b6 (diff) | |
parent | dfd070cea4c5cb1f6d7e4bf83c27cfd944a41761 (diff) | |
download | glib-78925535f98977bfb9ea5d03f1994c820ac439f3.tar.gz |
Merge branch 'backport-3200-write-limits-glib-2-74' into 'glib-2-74'
Backport !3200 “gfileutils: Use 'write' with 'count' <= max value of its return type” to glib-2-74
See merge request GNOME/glib!3204
-rw-r--r-- | glib/gfileutils.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/glib/gfileutils.c b/glib/gfileutils.c index f0c8f6776..722575ef6 100644 --- a/glib/gfileutils.c +++ b/glib/gfileutils.c @@ -1143,7 +1143,13 @@ write_to_file (const gchar *contents, { gssize s; - s = write (fd, contents, MIN (length, G_MAXSSIZE)); +#ifdef G_OS_WIN32 + /* 'write' on windows uses int types, so limit count to G_MAXINT */ + s = write (fd, contents, MIN (length, (gsize) G_MAXINT)); +#else + /* Limit count to G_MAXSSIZE to fit into the return value. */ + s = write (fd, contents, MIN (length, (gsize) G_MAXSSIZE)); +#endif if (s < 0) { |