Comment 4 for bug 1725829

Revision history for this message
Günter Rote (rote) wrote :

I found the following passage in dup_temp.py:

        if pr.compressed:
            gpg.GzipWriteFile(src_iter, tgt.name, size=sys.maxsize)
        elif pr.encrypted:
            gpg.GPGWriteFile(src_iter, tgt.name, globals.gpg_profile, size=sys.maxsize)

sys.maxsize = 2*31-1 on 32-bit systems.

When gpg.GzipWriteFile tries to write more bytes than the size parameter allows
it will quit and return False. (But for the signature file the return value is
not checked, in contrast to
the cases when the program writes the data itself. Those calls use the default size value.)

I guess the author meant to turn off the size check by choosing size=sys.maxsize
(instead of writing size=None and dealing properly with it.)

Here is what a supposed much simpler replacement function might look like, for one of these
functions (I haven't tested yet, and I don't understand the assert statement, which I
copied from the original).

def GzipWriteFile_without_size_constraint(block_iter, filename, gzipped=True):
    """
    Write gzipped compressed file, without size constraint

    Otherwise similar to GPGWriteFile
    """
    file_out = open(filename, "wb")
    # if gzipped wrap with GzipFile else plain file out
    if gzipped:
        outfile = gzip.GzipFile(None, "wb", 6, file_out)
    else:
        outfile = file_out
    for new_block in block_iter:
        outfile.write(new_block.data)
    assert not outfile.close() and not file_out.close()