bug-gnulib@gnu.org mirror (unofficial)
 help / color / mirror / Atom feed
From: Daiki Ueno <ueno@gnu.org>
To: Bruno Haible <bruno@clisp.org>
Cc: bug-gnulib@gnu.org
Subject: Re: [PATCH] read-file: add variants that clear internal memory
Date: Fri, 29 May 2020 05:59:44 +0200	[thread overview]
Message-ID: <87367jfl1r.fsf-ueno@gnu.org> (raw)
In-Reply-To: <1715829.BQkuVFqnNA@omega> (Bruno Haible's message of "Thu, 28 May 2020 22:09:59 +0200")

[-- Attachment #1: Type: text/plain, Size: 338 bytes --]

Bruno Haible <bruno@clisp.org> writes:

> Let me update the uses of the module 'read-file' in Gnulib.
> I think the next weekly CI run would have caught this.

Thank you; I completely missed those uses in Gnulib.

On a different note, it was suggested to disable stdio buffering if
RF_SENSITIVE is set.  I am attaching a patch for this.


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-read-file-disable-buffering-if-RF_SENSITIVE-is-set.patch --]
[-- Type: text/x-patch, Size: 1177 bytes --]

From 9165e495461db91b8abc42661fc543784d26d0d6 Mon Sep 17 00:00:00 2001
From: Daiki Ueno <ueno@gnu.org>
Date: Fri, 29 May 2020 05:45:40 +0200
Subject: [PATCH] read-file: disable buffering if RF_SENSITIVE is set

* lib/read-file.c (read_file): Call setvbuf if RF_SENSITIVE.
Suggested by Glenn Strauss.
---
 ChangeLog       | 6 ++++++
 lib/read-file.c | 3 +++
 2 files changed, 9 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index 77c637414..0a0e2301a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2020-05-29  Daiki Ueno  <ueno@gnu.org>
+
+	read-file: disable buffering if RF_SENSITIVE is set
+	* lib/read-file.c (read_file): Call setvbuf if RF_SENSITIVE.
+	Suggested by Glenn Strauss.
+
 2020-05-29  Daiki Ueno  <ueno@gnu.org>
 
 	fopen-gnu-tests: fix "\x" escape usage
diff --git a/lib/read-file.c b/lib/read-file.c
index 36780cc15..3520cbb7b 100644
--- a/lib/read-file.c
+++ b/lib/read-file.c
@@ -195,6 +195,9 @@ read_file (const char *filename, int flags, size_t *length)
   if (!stream)
     return NULL;
 
+  if (flags & RF_SENSITIVE)
+    setvbuf (stream, NULL, _IONBF, 0);
+
   out = fread_file (stream, flags, length);
 
   save_errno = errno;
-- 
2.26.2


[-- Attachment #3: Type: text/plain, Size: 25 bytes --]


Regards,
-- 
Daiki Ueno

  reply	other threads:[~2020-05-29  3:59 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-26  8:35 [PATCH] read-file: add variants that clear internal memory Daiki Ueno
2020-05-26 10:54 ` Bruno Haible
2020-05-26 16:32   ` Daiki Ueno
2020-05-26 18:33     ` Bruno Haible
2020-05-27  6:43       ` Daiki Ueno
2020-05-27 11:12         ` Bruno Haible
2020-05-27 12:18           ` Daiki Ueno
2020-05-28 20:09             ` Bruno Haible
2020-05-29  3:59               ` Daiki Ueno [this message]
2020-05-29  9:15                 ` Bruno Haible
2020-05-29 15:23                   ` Daiki Ueno

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://lists.gnu.org/mailman/listinfo/bug-gnulib

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87367jfl1r.fsf-ueno@gnu.org \
    --to=ueno@gnu.org \
    --cc=bruno@clisp.org \
    --cc=bug-gnulib@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).