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]);