guix-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug#35880] [PATCH 7/7] lzlib: 'lzread!' never returns more than it was


From: Ludovic Courtès
Subject: [bug#35880] [PATCH 7/7] lzlib: 'lzread!' never returns more than it was asked for.
Date: Sun, 26 May 2019 23:28:38 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.2 (gnu/linux)

Pierre Neidhardt <address@hidden> skribis:

> Ludovic Courtès <address@hidden> writes:
>
>> Pierre Neidhardt <address@hidden> skribis:
>>
>>>> Fixes a bug whereby 'lzread!' could return more than COUNT.
>>>
>>> Hmm... But why is this a bug?
>>
>> Because then the ‘read!’ method of the custom binary input port could
>> return more than ‘count’, which is understandably not permitted.
>
> That's the part where I'm a bit confused because we deal with compressed
> data here.
>
> So when we say "(read count)", does COUNT refer to the compressed or
> uncompressed data?

We have this:

  (define* (make-lzip-input-port port)
    (define decoder (lz-decompress-open))

    (define (read! bv start count)
      (lzread! decoder port bv start count))

    (make-custom-binary-input-port "lzip-input" read! #f #f
                                   (lambda () …)))

Here ‘read!’ must return an integer between 1 and COUNT; it must return
0 if and only if the end-of-file is reached.

IOW, ‘lzread!’ must return the number of uncompressed bytes of BV that
it consumed, and that number is necessarily <= COUNT.

Does that make sense?

Thanks,
Ludo’.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]