From: "Jan Šmydke" <jan.smydke@gmail.com>
To: 31528@debbugs.gnu.org
Subject: bug#31528: patch get-bytevector-n to read more than 4 GB
Date: Sat, 19 May 2018 13:10:15 +0200 [thread overview]
Message-ID: <CAP01H25sxMX-xRXj6eRj95=MoZDdpuEkM-CNwbze63Y-i6bTdw@mail.gmail.com> (raw)
[-- Attachment #1.1: Type: text/plain, Size: 495 bytes --]
Hi,
I found
(use-modules (rnrs io ports))
(define v (call-with-input-file "EIVE01.DAT" (lambda (port)
>
(get-bytevector-n port (* 5 1024 1024 1024)))))
>
fails due to 'out of range':
ERROR: In procedure get-bytevector-n:
ERROR: Value out of range 0 to 4294967295: 52434042880
The "count" variable was of "unsigned" type (i.e. 32-bit) so I changed it
to "size_t" and the problem is solved.
Enclosed is the corresponding patch (using format-patch)
Jan Šmydke
[-- Attachment #1.2: Type: text/html, Size: 1329 bytes --]
[-- Attachment #2: patch --]
[-- Type: application/octet-stream, Size: 1409 bytes --]
From 5b72b9d9c3cfa40884594eb1d403ec1d2f477d37 Mon Sep 17 00:00:00 2001
From: Jan Smydke <jan.smydke@gmail.com>
Date: Sat, 19 May 2018 12:48:01 +0200
Subject: [PATCH] get-bytevector-n and get-bytevector-n! can now read more than
4 GB: var "count" changed from unsigned to size_t
---
libguile/r6rs-ports.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/libguile/r6rs-ports.c b/libguile/r6rs-ports.c
index e944c7aab..00eea04a8 100644
--- a/libguile/r6rs-ports.c
+++ b/libguile/r6rs-ports.c
@@ -408,11 +408,11 @@ SCM_DEFINE (scm_get_bytevector_n, "get-bytevector-n", 2, 0, 0,
#define FUNC_NAME s_scm_get_bytevector_n
{
SCM result;
- unsigned c_count;
+ size_t c_count;
size_t c_read;
SCM_VALIDATE_BINARY_INPUT_PORT (1, port);
- c_count = scm_to_uint (count);
+ c_count = scm_to_size_t (count);
result = scm_c_make_bytevector (c_count);
@@ -444,13 +444,13 @@ SCM_DEFINE (scm_get_bytevector_n_x, "get-bytevector-n!", 4, 0, 0,
#define FUNC_NAME s_scm_get_bytevector_n_x
{
SCM result;
- unsigned c_start, c_count, c_len;
+ size_t c_start, c_count, c_len;
size_t c_read;
SCM_VALIDATE_BINARY_INPUT_PORT (1, port);
SCM_VALIDATE_BYTEVECTOR (2, bv);
- c_start = scm_to_uint (start);
- c_count = scm_to_uint (count);
+ c_start = scm_to_size_t (start);
+ c_count = scm_to_size_t (count);
c_len = SCM_BYTEVECTOR_LENGTH (bv);
--
2.11.0
next reply other threads:[~2018-05-19 11:10 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-19 11:10 Jan Šmydke [this message]
2018-06-18 12:05 ` bug#31528: patch get-bytevector-n to read more than 4 GB Ludovic Courtès
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://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAP01H25sxMX-xRXj6eRj95=MoZDdpuEkM-CNwbze63Y-i6bTdw@mail.gmail.com' \
--to=jan.smydke@gmail.com \
--cc=31528@debbugs.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).