diff options
author | Ludovic Courtès <ludo@gnu.org> | 2017-08-24 13:14:47 +0200 |
---|---|---|
committer | Ludovic Courtès <ludo@gnu.org> | 2017-08-24 23:55:51 +0200 |
commit | 94e86a6b67c7a02f5f11358743f3b9f11997059c (patch) | |
tree | 11a28c7422f0fcb366b4d263a4d635f693c83ee0 /guix/build | |
parent | 5e60bef9802e448924f889d34d95a249b008652c (diff) | |
download | gnu-guix-94e86a6b67c7a02f5f11358743f3b9f11997059c.tar gnu-guix-94e86a6b67c7a02f5f11358743f3b9f11997059c.tar.gz |
graft: Correctly replace references near the end of the scan buffer.
Fixes <http://bugs.gnu.org/28212>.
Reported by Leo Famulari <leo@famulari.name>.
* guix/build/graft.scm (replace-store-references): When I >= END, check
whether WRITTEN > END and call 'get-bytevector-n!' when it is.
* tests/grafts.scm (buffer-size): New variable.
("replace-store-references, <http://bugs.gnu.org/28212>"): New test.
Diffstat (limited to 'guix/build')
-rw-r--r-- | guix/build/graft.scm | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/guix/build/graft.scm b/guix/build/graft.scm index 16df169ec7..3dce486adf 100644 --- a/guix/build/graft.scm +++ b/guix/build/graft.scm @@ -164,15 +164,19 @@ bytevectors to the same value." ;; not to unget bytes that have already been written, because ;; that would cause them to be written again from the next ;; buffer. In practice, this case occurs when a replacement is - ;; made near the end of the buffer. - (let* ((unwritten (- end written)) - (unget-size (if (= end request-size) - (min hash-length unwritten) - 0)) - (write-size (- unwritten unget-size))) - (put-bytevector output buffer written write-size) - (unget-bytevector input buffer (+ written write-size) - unget-size) + ;; made near or beyond the end of the buffer. When REPLACEMENT + ;; went beyond END, we consume the extra bytes from INPUT. + (begin + (if (> written end) + (get-bytevector-n! input buffer 0 (- written end)) + (let* ((unwritten (- end written)) + (unget-size (if (= end request-size) + (min hash-length unwritten) + 0)) + (write-size (- unwritten unget-size))) + (put-bytevector output buffer written write-size) + (unget-bytevector input buffer (+ written write-size) + unget-size))) (loop))))))))) (define (rename-matching-files directory mapping) |