From owner-svn-soc-all@FreeBSD.ORG Mon Oct 28 11:16:59 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 18FC65C4 for ; Mon, 28 Oct 2013 11:16:59 +0000 (UTC) (envelope-from dpl@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 041EF2667 for ; Mon, 28 Oct 2013 11:16:59 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r9SBGwsA039713 for ; Mon, 28 Oct 2013 11:16:58 GMT (envelope-from dpl@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r9SBGw2w039707 for svn-soc-all@FreeBSD.org; Mon, 28 Oct 2013 11:16:58 GMT (envelope-from dpl@FreeBSD.org) Date: Mon, 28 Oct 2013 11:16:58 GMT Message-Id: <201310281116.r9SBGw2w039707@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to dpl@FreeBSD.org using -f From: dpl@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r259106 - soc2013/dpl/head/usr.bin/bsdiff/bsdiff MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Oct 2013 11:16:59 -0000 Author: dpl Date: Mon Oct 28 11:16:58 2013 New Revision: 259106 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=259106 Log: Use only one right and make the fd have coherent names. Modified: soc2013/dpl/head/usr.bin/bsdiff/bsdiff/bsdiff.c Modified: soc2013/dpl/head/usr.bin/bsdiff/bsdiff/bsdiff.c ============================================================================== --- soc2013/dpl/head/usr.bin/bsdiff/bsdiff/bsdiff.c Mon Oct 28 10:32:14 2013 (r259105) +++ soc2013/dpl/head/usr.bin/bsdiff/bsdiff/bsdiff.c Mon Oct 28 11:16:58 2013 (r259106) @@ -197,7 +197,7 @@ int main(int argc,char *argv[]) { - int first, second; + int oldfd,newfd; u_char *old,*new; off_t oldsize,newsize; off_t *I,*V; @@ -218,35 +218,40 @@ if(argc!=4) errx(1,"usage: %s oldfile newfile patchfile\n",argv[0]); - if ((first = open(argv[1],O_RDONLY|O_BINARY,0)) < 0) + /* Capsicum */ + if ((oldfd = open(argv[1],O_RDONLY|O_BINARY,0)) < 0) err(1,"%s",argv[1]); - if ((second = open(argv[2], O_RDONLY|O_BINARY, 0)) < 0) + if ((newfd = open(argv[2],O_RDONLY|O_BINARY,0)) < 0) err(1,"%s",argv[1]); /* Create the patch file */ - if ((pf = fopen(argv[3], "wb")) == NULL) - err(1, "%s", argv[3]); + if ((pf = fopen(argv[3],"wb")) == NULL) + err(1,"%s",argv[3]); - cap_rights_init(&rights, CAP_READ, CAP_SEEK); - - if (cap_rights_limit(first, &filerights) < 0 && errno != ENOSYS) - err(1, "Couldn't limit fd"); - if (cap_rights_limit(second, &filerights) < 0 && errno != ENOSYS) - err(1, "Couldn't limit fd"); - - cap_rights_set(&rights, CAP_WRITE, CAP_SEEK); - if (cap_rights_limit(fileno(pf), &pathrights) < 0 && errno != ENOSYS) - err(1, "Couldn't limit fd"); + cap_rights_init(&rights,CAP_READ,CAP_SEEK); + if (cap_rights_limit(oldfd,&filerights) < 0 && errno != ENOSYS) + err(1,"Couldn't limit fd"); + if (cap_rights_limit(newfd,&filerights) < 0 && errno != ENOSYS) + err(1,"Couldn't limit fd"); + + cap_rights_init(&rights,CAP_WRITE,CAP_SEEK); + if (cap_rights_limit(fileno(pf),&pathrights) < 0 && errno != ENOSYS) + err(1,"Couldn't limit fd"); if (cap_enter() < 0 && errno != ENOSYS) - err(1, "Couldn't enter capability mode"); + err(1,"Couldn't enter capability mode"); /* Allocate oldsize+1 bytes instead of oldsize bytes to ensure that we never try to malloc(0) and get a NULL pointer */ - if(((oldsize=lseek(first,0,SEEK_END))==-1) || - ((old=malloc(oldsize+1))==NULL) || - (lseek(first,0,SEEK_SET)!=0) || - (read(first,old,oldsize)!=oldsize) || - (close(first)==-1)) err(1,"%s",argv[1]); + if ((oldsize = lseek(oldfd,0,SEEK_END)) == -1) + err(1,"%s",argv[1]); + if ((old = malloc(oldsize + 1)) == NULL) + err(1,"%s",argv[1]); + if ((lseek(oldfd,0,SEEK_SET) != 0) + err(1,"%s",argv[1]); + if (read(oldfd,old,oldsize) != oldsize) + err(1,"%s",argv[1]); + if (close(oldfd) == -1) + err(1,"%s",argv[1]); if(((I=malloc((oldsize+1)*sizeof(off_t)))==NULL) || ((V=malloc((oldsize+1)*sizeof(off_t)))==NULL)) err(1,NULL); @@ -257,11 +262,16 @@ /* Allocate newsize+1 bytes instead of newsize bytes to ensure that we never try to malloc(0) and get a NULL pointer */ - if(((newsize=lseek(second,0,SEEK_END))==-1) || - ((new=malloc(newsize+1))==NULL) || - (lseek(second,0,SEEK_SET)!=0) || - (read(second,new,newsize)!=newsize) || - (close(second)==-1)) err(1,"%s",argv[2]); + if ((newsize = lseek(newfd,0,SEEK_END)) == -1) + err(1,"%s",argv[1]); + if ((old = malloc(newsize + 1)) == NULL) + err(1,"%s",argv[1]); + if ((lseek(newfd,0,SEEK_SET) != 0) + err(1,"%s",argv[1]); + if (read(newfd,old,newsize) != newsize) + err(1,"%s",argv[1]); + if (close(newfd) == -1) + err(1,"%s",argv[1]); if(((db=malloc(newsize+1))==NULL) || ((eb=malloc(newsize+1))==NULL)) err(1,NULL); @@ -288,8 +298,15 @@ /* Compute the differences, writing ctrl as we go */ if ((pfbz2 = BZ2_bzWriteOpen(&bz2err, pf, 9, 0, 0)) == NULL) errx(1, "BZ2_bzWriteOpen, bz2err = %d", bz2err); - scan=0;len=0;pos=0; - lastscan=0;lastpos=0;lastoffset=0; + + scan=0; + len=0; + pos=0; + + lastscan=0; + lastpos=0; + lastoffset=0; + while(scan Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 90F0AA14 for ; Mon, 28 Oct 2013 23:02:26 +0000 (UTC) (envelope-from dpl@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 7D849266E for ; Mon, 28 Oct 2013 23:02:26 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r9SN2QXk045572 for ; Mon, 28 Oct 2013 23:02:26 GMT (envelope-from dpl@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r9SN2QZA045563 for svn-soc-all@FreeBSD.org; Mon, 28 Oct 2013 23:02:26 GMT (envelope-from dpl@FreeBSD.org) Date: Mon, 28 Oct 2013 23:02:26 GMT Message-Id: <201310282302.r9SN2QZA045563@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to dpl@FreeBSD.org using -f From: dpl@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r259147 - in soc2013/dpl/head/usr.bin/bsdiff: bsdiff bspatch MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 28 Oct 2013 23:02:26 -0000 Author: dpl Date: Mon Oct 28 23:02:26 2013 New Revision: 259147 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=259147 Log: Add comments regarding future compatibility with Casper. Modified: soc2013/dpl/head/usr.bin/bsdiff/bsdiff/bsdiff.c soc2013/dpl/head/usr.bin/bsdiff/bspatch/bspatch.c Modified: soc2013/dpl/head/usr.bin/bsdiff/bsdiff/bsdiff.c ============================================================================== --- soc2013/dpl/head/usr.bin/bsdiff/bsdiff/bsdiff.c Mon Oct 28 22:54:28 2013 (r259146) +++ soc2013/dpl/head/usr.bin/bsdiff/bsdiff/bsdiff.c Mon Oct 28 23:02:26 2013 (r259147) @@ -223,7 +223,10 @@ err(1,"%s",argv[1]); if ((newfd = open(argv[2],O_RDONLY|O_BINARY,0)) < 0) err(1,"%s",argv[1]); - /* Create the patch file */ + /* + * Create the patch file. + * It should get unliked if there's any error, possibly using Casper. + */ if ((pf = fopen(argv[3],"wb")) == NULL) err(1,"%s",argv[3]); Modified: soc2013/dpl/head/usr.bin/bsdiff/bspatch/bspatch.c ============================================================================== --- soc2013/dpl/head/usr.bin/bsdiff/bspatch/bspatch.c Mon Oct 28 22:54:28 2013 (r259146) +++ soc2013/dpl/head/usr.bin/bsdiff/bspatch/bspatch.c Mon Oct 28 23:02:26 2013 (r259147) @@ -78,9 +78,13 @@ /* Capsicum */ if ((oldfd = open(argv[1],O_RDONLY|O_BINARY,0)) < 0) err(1,"%s",argv[1]); + /* + * Create the new file. + * It should get unliked if there's any error, possibly using Casper. + */ if ((newfd = open(argv[2],O_CREAT|O_TRUNC|O_WRONLY|O_BINARY,0666)) < 0) err(1,"%s",argv[1]); - /* Open patch file */ + /* Open the patch file. */ if ((f = fopen(argv[3], "rb")) == NULL) err(1, "fopen(%s)", argv[3]); if ((cpf = fopen(argv[3], "rb")) == NULL) From owner-svn-soc-all@FreeBSD.ORG Tue Oct 29 08:54:06 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 6B4FF586 for ; Tue, 29 Oct 2013 08:54:06 +0000 (UTC) (envelope-from dpl@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 5824B2503 for ; Tue, 29 Oct 2013 08:54:06 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r9T8s6up009819 for ; Tue, 29 Oct 2013 08:54:06 GMT (envelope-from dpl@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r9T8s6xV009812 for svn-soc-all@FreeBSD.org; Tue, 29 Oct 2013 08:54:06 GMT (envelope-from dpl@FreeBSD.org) Date: Tue, 29 Oct 2013 08:54:06 GMT Message-Id: <201310290854.r9T8s6xV009812@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to dpl@FreeBSD.org using -f From: dpl@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r259173 - soc2013/dpl/head/usr.bin/bsdiff/bspatch MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 29 Oct 2013 08:54:06 -0000 Author: dpl Date: Tue Oct 29 08:54:05 2013 New Revision: 259173 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=259173 Log: Added include errno. Modified: soc2013/dpl/head/usr.bin/bsdiff/bspatch/bspatch.c Modified: soc2013/dpl/head/usr.bin/bsdiff/bspatch/bspatch.c ============================================================================== --- soc2013/dpl/head/usr.bin/bsdiff/bspatch/bspatch.c Tue Oct 29 07:48:36 2013 (r259172) +++ soc2013/dpl/head/usr.bin/bsdiff/bspatch/bspatch.c Tue Oct 29 08:54:05 2013 (r259173) @@ -32,6 +32,7 @@ #include #include #include +#include #include #include From owner-svn-soc-all@FreeBSD.ORG Wed Oct 30 20:08:43 2013 Return-Path: Delivered-To: svn-soc-all@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id D4D8974F for ; Wed, 30 Oct 2013 20:08:43 +0000 (UTC) (envelope-from dpl@FreeBSD.org) Received: from socsvn.freebsd.org (socsvn.freebsd.org [IPv6:2001:1900:2254:206a::50:2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id A60EC2FB2 for ; Wed, 30 Oct 2013 20:08:43 +0000 (UTC) Received: from socsvn.freebsd.org ([127.0.1.124]) by socsvn.freebsd.org (8.14.7/8.14.7) with ESMTP id r9UK8hcJ068774 for ; Wed, 30 Oct 2013 20:08:43 GMT (envelope-from dpl@FreeBSD.org) Received: (from www@localhost) by socsvn.freebsd.org (8.14.7/8.14.6/Submit) id r9UK8hwB068768 for svn-soc-all@FreeBSD.org; Wed, 30 Oct 2013 20:08:43 GMT (envelope-from dpl@FreeBSD.org) Date: Wed, 30 Oct 2013 20:08:43 GMT Message-Id: <201310302008.r9UK8hwB068768@socsvn.freebsd.org> X-Authentication-Warning: socsvn.freebsd.org: www set sender to dpl@FreeBSD.org using -f From: dpl@FreeBSD.org To: svn-soc-all@FreeBSD.org Subject: socsvn commit: r259257 - soc2013/dpl/head/usr.bin/bsdiff/bsdiff MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-soc-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the entire Summer of Code repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 30 Oct 2013 20:08:43 -0000 Author: dpl Date: Wed Oct 30 20:08:43 2013 New Revision: 259257 URL: http://svnweb.FreeBSD.org/socsvn/?view=rev&rev=259257 Log: Make bsdiff allocate new. Modified: soc2013/dpl/head/usr.bin/bsdiff/bsdiff/bsdiff.c Modified: soc2013/dpl/head/usr.bin/bsdiff/bsdiff/bsdiff.c ============================================================================== --- soc2013/dpl/head/usr.bin/bsdiff/bsdiff/bsdiff.c Wed Oct 30 18:40:55 2013 (r259256) +++ soc2013/dpl/head/usr.bin/bsdiff/bsdiff/bsdiff.c Wed Oct 30 20:08:43 2013 (r259257) @@ -32,6 +32,7 @@ #include #include +#include #include #include #include @@ -231,13 +232,13 @@ err(1,"%s",argv[3]); cap_rights_init(&rights,CAP_READ,CAP_SEEK); - if (cap_rights_limit(oldfd,&filerights) < 0 && errno != ENOSYS) + if (cap_rights_limit(oldfd,&rights) < 0 && errno != ENOSYS) err(1,"Couldn't limit fd"); - if (cap_rights_limit(newfd,&filerights) < 0 && errno != ENOSYS) + if (cap_rights_limit(newfd,&rights) < 0 && errno != ENOSYS) err(1,"Couldn't limit fd"); cap_rights_init(&rights,CAP_WRITE,CAP_SEEK); - if (cap_rights_limit(fileno(pf),&pathrights) < 0 && errno != ENOSYS) + if (cap_rights_limit(fileno(pf),&rights) < 0 && errno != ENOSYS) err(1,"Couldn't limit fd"); if (cap_enter() < 0 && errno != ENOSYS) @@ -249,7 +250,7 @@ err(1,"%s",argv[1]); if ((old = malloc(oldsize + 1)) == NULL) err(1,"%s",argv[1]); - if ((lseek(oldfd,0,SEEK_SET) != 0) + if (lseek(oldfd,0,SEEK_SET) != 0) err(1,"%s",argv[1]); if (read(oldfd,old,oldsize) != oldsize) err(1,"%s",argv[1]); @@ -267,9 +268,11 @@ that we never try to malloc(0) and get a NULL pointer */ if ((newsize = lseek(newfd,0,SEEK_END)) == -1) err(1,"%s",argv[1]); + if ((new=malloc(newsize+1)) == NULL) + err(1,"%s",argv[1]); if ((old = malloc(newsize + 1)) == NULL) err(1,"%s",argv[1]); - if ((lseek(newfd,0,SEEK_SET) != 0) + if (lseek(newfd,0,SEEK_SET) != 0) err(1,"%s",argv[1]); if (read(newfd,old,newsize) != newsize) err(1,"%s",argv[1]);