[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
branch master updated: * info/nodes.c (info_reload_file_buffer_contents)
From: |
Patrice Dumas |
Subject: |
branch master updated: * info/nodes.c (info_reload_file_buffer_contents): add an intermediate variable for filesize passed to filesys_read_info_file. |
Date: |
Wed, 09 Oct 2024 07:43:38 -0400 |
This is an automated email from the git hooks/post-receive script.
pertusus pushed a commit to branch master
in repository texinfo.
The following commit(s) were added to refs/heads/master by this push:
new c1fd449e8f * info/nodes.c (info_reload_file_buffer_contents): add an
intermediate variable for filesize passed to filesys_read_info_file.
c1fd449e8f is described below
commit c1fd449e8f746e04fb7441ac657c9ad33a272097
Author: Patrice Dumas <pertusus@free.fr>
AuthorDate: Wed Oct 9 13:43:26 2024 +0200
* info/nodes.c (info_reload_file_buffer_contents): add an intermediate
variable for filesize passed to filesys_read_info_file.
* info/nodes.h (FILE_BUFFER), info/nodes.c
(info_reload_file_buffer_contents, info_load_file): use long for
filesize instead of size_t to be sure that comparisons with node and
search length are always safe. Add comments to explicit where the
conversion from size_t to long is done.
---
ChangeLog | 11 +++++++++++
info/nodes.c | 9 ++++++++-
info/nodes.h | 3 ++-
3 files changed, 21 insertions(+), 2 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index d04a368a2d..fd1a9d0ffa 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2024-10-09 Patrice Dumas <pertusus@free.fr>
+
+ * info/nodes.c (info_reload_file_buffer_contents): add an intermediate
+ variable for filesize passed to filesys_read_info_file.
+
+ * info/nodes.h (FILE_BUFFER), info/nodes.c
+ (info_reload_file_buffer_contents, info_load_file): use long for
+ filesize instead of size_t to be sure that comparisons with node and
+ search length are always safe. Add comments to explicit where the
+ conversion from size_t to long is done.
+
2024-10-09 Patrice Dumas <pertusus@free.fr>
* info/nodes.c (info_create_node): use consistent type.
diff --git a/info/nodes.c b/info/nodes.c
index 380a1403b6..154933f68d 100644
--- a/info/nodes.c
+++ b/info/nodes.c
@@ -742,6 +742,8 @@ info_load_file (char *fullpath, int is_subfile)
*p = '\0';
}
file_buffer->finfo = finfo;
+ /* NOTE conversion from size_t to long here to be sure that comparisons with
+ node and search length are always safe. */
file_buffer->filesize = filesize;
file_buffer->contents = contents;
if (compressed)
@@ -856,13 +858,18 @@ static void
info_reload_file_buffer_contents (FILE_BUFFER *fb)
{
int is_compressed;
+ size_t filesize;
fb->flags &= ~N_IsCompressed;
/* Let the filesystem do all the work for us. */
fb->contents =
- filesys_read_info_file (fb->fullpath, &(fb->filesize), &(fb->finfo),
+ filesys_read_info_file (fb->fullpath, &filesize, &(fb->finfo),
&is_compressed);
+ /* NOTE conversion from size_t to long here to be sure that comparisons with
+ node and search length are always safe. */
+ fb->filesize = filesize;
+
if (is_compressed)
fb->flags |= N_IsCompressed;
}
diff --git a/info/nodes.h b/info/nodes.h
index 8f60e542f9..02bba9925b 100644
--- a/info/nodes.h
+++ b/info/nodes.h
@@ -119,7 +119,8 @@ typedef struct {
char *fullpath; /* The full pathname of this info file. */
struct stat finfo; /* Information about this file. */
char *contents; /* The contents of this particular file. */
- size_t filesize; /* The number of bytes this file expands to. */
+ long filesize; /* The number of bytes this file expands to.
+ Should not be negative */
char **subfiles; /* If non-null, the list of subfiles. */
TAG **tags; /* If non-null, the tags table. */
size_t tags_slots; /* Number of slots allocated for TAGS. */
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- branch master updated: * info/nodes.c (info_reload_file_buffer_contents): add an intermediate variable for filesize passed to filesys_read_info_file.,
Patrice Dumas <=