[glib: 2/3] Don't pass more than G_MAXSSIZE bytes at once to write() in glib/gfileutils.c
- From: Sebastian Dröge <sdroege src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glib: 2/3] Don't pass more than G_MAXSSIZE bytes at once to write() in glib/gfileutils.c
- Date: Thu, 27 Aug 2020 16:50:38 +0000 (UTC)
commit dae128e6bb83f27605430b5b5661ba331d102926
Author: Sebastian Dröge <sebastian centricular com>
Date: Thu Aug 27 17:42:28 2020 +0200
Don't pass more than G_MAXSSIZE bytes at once to write() in glib/gfileutils.c
Behaviour in that case is implementation-defined and how many bytes were
actually written can't be expressed by the return value anymore.
Instead do a short write of G_MAXSSIZE bytes and let the existing loop
for handling short writes takes care of the remaining length.
glib/gfileutils.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
---
diff --git a/glib/gfileutils.c b/glib/gfileutils.c
index 8992203d6..46f200ddf 100644
--- a/glib/gfileutils.c
+++ b/glib/gfileutils.c
@@ -1157,7 +1157,7 @@ write_to_file (const gchar *contents,
{
gssize s;
- s = write (fd, contents, length);
+ s = write (fd, contents, MIN (length, G_MAXSSIZE));
if (s < 0)
{
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]