Skip to content

bsdiff with zlib instead of bz2 #34

Description

@balix-microej

Hello,

Is bsdiff compatible with other compression libraries?

I need a version with zlib, so I tried replacing bz2 write/read with zlib equivalent.

bsdiff seems to work however when running bspatch the sanity check fails every time:

		/* Sanity-check */
		if (ctrl[0]<0 || ctrl[0]>INT_MAX ||
			ctrl[1]<0 || ctrl[1]>INT_MAX ||
			newpos+ctrl[0]>newsize)
			return -1;

I don't understand why but the values in the ctrl array are way too high are negative.

This is what I got by running a debug session:

(gdb) p ctrl
$1 = {2248591341461585215, -5979881847581223336, -7917639821140655946}

Opposed to the bz2 version which can give something like this:

(gdb) p ctrl
$4 = {0, 3000, 589}

Is there any advice to adapt bsdiff for a different compression method?

Thanks,

Benjamin

PS: here are the stream functions I adapted to zlib:

static int bz2_read(const struct bspatch_stream* stream, void* buffer, int length)
{
	int bytes;
	gzFile* gz;

	gz = (gzFile*) stream->opaque;
	bytes = gzread(*gz, buffer, length);
	if (0 == bytes) {
		return -1;
	}

	return 0;
}

static int bz2_write(struct bsdiff_stream* stream, const void* buffer, int size)
{
	int bytes;
	gzFile* gz;

	gz = (gzFile*) stream->opaque;
	bytes = gzwrite(*gz, buffer, size);
	if (0 == bytes) {
		return -1;
	}

	return 0;
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions