[Midnightbsd-cvs] src [11526] trunk/usr.bin/bsdiff/bspatch/bspatch.c: sync bsdiff with freebsd.
laffer1 at midnightbsd.org
laffer1 at midnightbsd.org
Sat Jul 7 15:27:43 EDT 2018
Revision: 11526
http://svnweb.midnightbsd.org/src/?rev=11526
Author: laffer1
Date: 2018-07-07 15:27:42 -0400 (Sat, 07 Jul 2018)
Log Message:
-----------
sync bsdiff with freebsd.
Modified Paths:
--------------
trunk/usr.bin/bsdiff/Makefile
trunk/usr.bin/bsdiff/Makefile.inc
trunk/usr.bin/bsdiff/bsdiff/Makefile
trunk/usr.bin/bsdiff/bsdiff/bsdiff.1
trunk/usr.bin/bsdiff/bsdiff/bsdiff.c
trunk/usr.bin/bsdiff/bspatch/Makefile
trunk/usr.bin/bsdiff/bspatch/bspatch.1
trunk/usr.bin/bsdiff/bspatch/bspatch.c
Property Changed:
----------------
trunk/usr.bin/bsdiff/Makefile.inc
trunk/usr.bin/bsdiff/bsdiff/bsdiff.1
trunk/usr.bin/bsdiff/bspatch/bspatch.1
Modified: trunk/usr.bin/bsdiff/Makefile
===================================================================
--- trunk/usr.bin/bsdiff/Makefile 2018-07-07 19:26:52 UTC (rev 11525)
+++ trunk/usr.bin/bsdiff/Makefile 2018-07-07 19:27:42 UTC (rev 11526)
@@ -1,4 +1,5 @@
-# $FreeBSD: src/usr.bin/bsdiff/Makefile,v 1.1.2.1 2005/08/15 18:34:21 cperciva Exp $
+# $MidnightBSD$
+# $FreeBSD: stable/10/usr.bin/bsdiff/Makefile 148771 2005-08-06 01:59:06Z cperciva $
SUBDIR= bsdiff bspatch
Modified: trunk/usr.bin/bsdiff/Makefile.inc
===================================================================
--- trunk/usr.bin/bsdiff/Makefile.inc 2018-07-07 19:26:52 UTC (rev 11525)
+++ trunk/usr.bin/bsdiff/Makefile.inc 2018-07-07 19:27:42 UTC (rev 11526)
@@ -1,4 +1,4 @@
-# $FreeBSD: src/usr.bin/bsdiff/Makefile.inc,v 1.2.2.1 2005/08/15 18:34:21 cperciva Exp $
+# $MidnightBSD$
+# $FreeBSD: stable/10/usr.bin/bsdiff/Makefile.inc 201386 2010-01-02 10:27:05Z ed $
.include "../Makefile.inc"
-
Property changes on: trunk/usr.bin/bsdiff/Makefile.inc
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/usr.bin/bsdiff/bsdiff/Makefile
===================================================================
--- trunk/usr.bin/bsdiff/bsdiff/Makefile 2018-07-07 19:26:52 UTC (rev 11525)
+++ trunk/usr.bin/bsdiff/bsdiff/Makefile 2018-07-07 19:27:42 UTC (rev 11526)
@@ -1,4 +1,5 @@
# $MidnightBSD$
+# $FreeBSD: stable/10/usr.bin/bsdiff/bsdiff/Makefile 148771 2005-08-06 01:59:06Z cperciva $
PROG= bsdiff
Modified: trunk/usr.bin/bsdiff/bsdiff/bsdiff.1
===================================================================
--- trunk/usr.bin/bsdiff/bsdiff/bsdiff.1 2018-07-07 19:26:52 UTC (rev 11525)
+++ trunk/usr.bin/bsdiff/bsdiff/bsdiff.1 2018-07-07 19:27:42 UTC (rev 11526)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\"-
.\" Copyright 2003-2005 Colin Percival
.\" All rights reserved
@@ -23,7 +24,7 @@
.\" IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/usr.bin/bsdiff/bsdiff/bsdiff.1 233648 2012-03-29 05:02:12Z eadler $
.\"
.Dd May 18, 2003
.Dt BSDIFF 1
Property changes on: trunk/usr.bin/bsdiff/bsdiff/bsdiff.1
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/usr.bin/bsdiff/bsdiff/bsdiff.c
===================================================================
--- trunk/usr.bin/bsdiff/bsdiff/bsdiff.c 2018-07-07 19:26:52 UTC (rev 11525)
+++ trunk/usr.bin/bsdiff/bsdiff/bsdiff.c 2018-07-07 19:27:42 UTC (rev 11526)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright 2003-2005 Colin Percival
* All rights reserved
@@ -25,13 +26,16 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/usr.bin/bsdiff/bsdiff/bsdiff.c 306214 2016-09-22 21:14:00Z emaste $");
#include <sys/types.h>
#include <bzlib.h>
#include <err.h>
+#include <errno.h>
#include <fcntl.h>
+#include <limits.h>
+#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -196,6 +200,14 @@
if(x<0) buf[7]|=0x80;
}
+static void
+usage(void)
+{
+
+ fprintf(stderr, "usage: bsdiff oldfile newfile patchfile\n");
+ exit(1);
+}
+
int main(int argc,char *argv[])
{
int fd;
@@ -216,13 +228,23 @@
BZFILE * pfbz2;
int bz2err;
- if(argc!=4) errx(1,"usage: %s oldfile newfile patchfile\n",argv[0]);
+ if (argc != 4)
+ usage();
/* Allocate oldsize+1 bytes instead of oldsize bytes to ensure
that we never try to malloc(0) and get a NULL pointer */
if(((fd=open(argv[1],O_RDONLY|O_BINARY,0))<0) ||
- ((oldsize=lseek(fd,0,SEEK_END))==-1) ||
- ((old=malloc(oldsize+1))==NULL) ||
+ ((oldsize=lseek(fd,0,SEEK_END))==-1))
+ err(1, "%s", argv[1]);
+
+ if (oldsize > SSIZE_MAX ||
+ (uintmax_t)oldsize >= SIZE_T_MAX / sizeof(off_t) ||
+ oldsize == OFF_MAX) {
+ errno = EFBIG;
+ err(1, "%s", argv[1]);
+ }
+
+ if (((old=malloc(oldsize+1))==NULL) ||
(lseek(fd,0,SEEK_SET)!=0) ||
(read(fd,old,oldsize)!=oldsize) ||
(close(fd)==-1)) err(1,"%s",argv[1]);
@@ -237,8 +259,16 @@
/* Allocate newsize+1 bytes instead of newsize bytes to ensure
that we never try to malloc(0) and get a NULL pointer */
if(((fd=open(argv[2],O_RDONLY|O_BINARY,0))<0) ||
- ((newsize=lseek(fd,0,SEEK_END))==-1) ||
- ((new=malloc(newsize+1))==NULL) ||
+ ((newsize=lseek(fd,0,SEEK_END))==-1))
+ err(1, "%s", argv[2]);
+
+ if (newsize > SSIZE_MAX || (uintmax_t)newsize >= SIZE_T_MAX ||
+ newsize == OFF_MAX) {
+ errno = EFBIG;
+ err(1, "%s", argv[2]);
+ }
+
+ if (((new=malloc(newsize+1))==NULL) ||
(lseek(fd,0,SEEK_SET)!=0) ||
(read(fd,new,newsize)!=newsize) ||
(close(fd)==-1)) err(1,"%s",argv[2]);
Modified: trunk/usr.bin/bsdiff/bspatch/Makefile
===================================================================
--- trunk/usr.bin/bsdiff/bspatch/Makefile 2018-07-07 19:26:52 UTC (rev 11525)
+++ trunk/usr.bin/bsdiff/bspatch/Makefile 2018-07-07 19:27:42 UTC (rev 11526)
@@ -1,4 +1,5 @@
# $MidnightBSD$
+# $FreeBSD: stable/10/usr.bin/bsdiff/bspatch/Makefile 148771 2005-08-06 01:59:06Z cperciva $
PROG= bspatch
Modified: trunk/usr.bin/bsdiff/bspatch/bspatch.1
===================================================================
--- trunk/usr.bin/bsdiff/bspatch/bspatch.1 2018-07-07 19:26:52 UTC (rev 11525)
+++ trunk/usr.bin/bsdiff/bspatch/bspatch.1 2018-07-07 19:27:42 UTC (rev 11526)
@@ -1,3 +1,4 @@
+.\" $MidnightBSD$
.\"-
.\" Copyright 2003-2005 Colin Percival
.\" All rights reserved
@@ -23,7 +24,7 @@
.\" IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
-.\" $MidnightBSD$
+.\" $FreeBSD: stable/10/usr.bin/bsdiff/bspatch/bspatch.1 208027 2010-05-13 12:07:55Z uqs $
.\"
.Dd May 18, 2003
.Dt BSPATCH 1
Property changes on: trunk/usr.bin/bsdiff/bspatch/bspatch.1
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/usr.bin/bsdiff/bspatch/bspatch.c
===================================================================
--- trunk/usr.bin/bsdiff/bspatch/bspatch.c 2018-07-07 19:26:52 UTC (rev 11525)
+++ trunk/usr.bin/bsdiff/bspatch/bspatch.c 2018-07-07 19:27:42 UTC (rev 11526)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright 2003-2005 Colin Percival
* All rights reserved
@@ -25,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/usr.bin/bsdiff/bspatch/bspatch.c 306215 2016-09-22 21:16:54Z emaste $");
#if defined(__FreeBSD__)
#include <sys/param.h>
@@ -83,6 +84,14 @@
return (y);
}
+static void
+usage(void)
+{
+
+ fprintf(stderr, "usage: bspatch oldfile newfile patchfile\n");
+ exit(1);
+}
+
int main(int argc, char *argv[])
{
FILE *f, *cpf, *dpf, *epf;
@@ -101,7 +110,8 @@
cap_rights_t rights_dir, rights_ro, rights_wr;
#endif
- if(argc!=4) errx(1,"usage: %s oldfile newfile patchfile\n",argv[0]);
+ if (argc != 4)
+ usage();
/* Open patch file */
if ((f = fopen(argv[3], "rb")) == NULL)
@@ -228,7 +238,7 @@
(cbz2err != BZ_STREAM_END)))
errx(1, "Corrupt patch");
ctrl[i] = offtin(buf);
- };
+ }
/* Sanity-check */
if (ctrl[0] < 0 || ctrl[0] > INT_MAX ||
@@ -267,7 +277,7 @@
/* Adjust pointers */
newpos+=ctrl[1];
oldpos+=ctrl[2];
- };
+ }
/* Clean up the bzip2 reads */
BZ2_bzReadClose(&cbz2err, cpfbz2);
More information about the Midnightbsd-cvs
mailing list