New upstream version 2022.1

This commit is contained in:
Simon McVittie committed 2022-01-07 10:35:19 +00:00
commit 13edc15773
444 files changed
+968 -1498

No files matched your search

+5 -5
View File
@@ -4,11 +4,11 @@ bsdiff and bspatch are libraries for building and applying patches to binary
files.
The original algorithm and implementation was developed by Colin Percival. The
algorithm is detailed in his (unpublished) paper, [Naïve Differences of Executable Code](http://www.daemonology.net/papers/bsdiff.pdf). For more information, visit his
algorithm is detailed in his paper, [Naïve Differences of Executable Code](http://www.daemonology.net/papers/bsdiff.pdf). For more information, visit his
website at <http://www.daemonology.net/bsdiff/>.
I maintain this project seperately from Colin's work, with the goal of making
the core functionality easily embedable in existing projects.
I maintain this project separately from Colin's work, with the goal of making
the core functionality easily embeddable in existing projects.
Contact
-------
@@ -37,7 +37,7 @@ I've exposed relevant functions via the `_stream` classes. The only external
dependency not exposed is `memcmp` in `bsdiff`.
This library generates patches that are not compatible with the original bsdiff
tool. The impompatibilities were motivated by the patching needs for the game
tool. The incompatibilities were motivated by the patching needs for the game
AirMech <https://www.carbongames.com> and the following requirements:
* Eliminate/minimize any seek operations when applying patches
@@ -82,7 +82,7 @@ Reference
In order to use `bsdiff`, you need to define functions for allocating memory and
writing binary data. This behavior is controlled by the `stream` parameted
writing binary data. This behavior is controlled by the `stream` parameter
passed to to `bsdiff(...)`.
The `opaque` field is never read or modified from within the `bsdiff` function.
+10 -3
View File
@@ -1,4 +1,4 @@
/*-
/*-
* Copyright 2003-2005 Colin Percival
* Copyright 2012 Matthew Endsley
* All rights reserved
@@ -25,6 +25,7 @@
* POSSIBILITY OF SUCH DAMAGE.
*/
#include <limits.h>
#include "bspatch.h"
static int64_t offtin(uint8_t *buf)
@@ -62,7 +63,9 @@ int bspatch(const uint8_t* old, int64_t oldsize, uint8_t* new, int64_t newsize,
};
/* Sanity-check */
if(newpos+ctrl[0]>newsize)
if (ctrl[0]<0 || ctrl[0]>INT_MAX ||
ctrl[1]<0 || ctrl[1]>INT_MAX ||
newpos+ctrl[0]>newsize)
return -1;
/* Read diff string */
@@ -102,6 +105,8 @@ int bspatch(const uint8_t* old, int64_t oldsize, uint8_t* new, int64_t newsize,
#include <stdio.h>
#include <string.h>
#include <err.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <fcntl.h>
@@ -129,6 +134,7 @@ int main(int argc,char * argv[])
int64_t oldsize, newsize;
BZFILE* bz2;
struct bspatch_stream stream;
struct stat sb;
if(argc!=4) errx(1,"usage: %s oldfile newfile patchfile\n",argv[0]);
@@ -158,6 +164,7 @@ int main(int argc,char * argv[])
((old=malloc(oldsize+1))==NULL) ||
(lseek(fd,0,SEEK_SET)!=0) ||
(read(fd,old,oldsize)!=oldsize) ||
(fstat(fd, &sb)) ||
(close(fd)==-1)) err(1,"%s",argv[1]);
if((new=malloc(newsize+1))==NULL) err(1,NULL);
@@ -174,7 +181,7 @@ int main(int argc,char * argv[])
fclose(f);
/* Write the new file */
if(((fd=open(argv[2],O_CREAT|O_TRUNC|O_WRONLY,0666))<0) ||
if(((fd=open(argv[2],O_CREAT|O_TRUNC|O_WRONLY,sb.st_mode))<0) ||
(write(fd,new,newsize)!=newsize) || (close(fd)==-1))
err(1,"%s",argv[2]);