diff options
author | joerg <joerg@pkgsrc.org> | 2009-10-21 17:17:04 +0000 |
---|---|---|
committer | joerg <joerg@pkgsrc.org> | 2009-10-21 17:17:04 +0000 |
commit | 67c9719d1a3a9b309b8e13d9a954ee57cfa5d154 (patch) | |
tree | 9a6df5b59a5c5f33f6750dc6817426d59bf9ff51 | |
parent | 6f43c89cc7a08934f3024b0fc81d80619c4821b5 (diff) | |
download | pkgsrc-67c9719d1a3a9b309b8e13d9a954ee57cfa5d154.tar.gz |
nbpatch-20091021:
Do not try to mmap a zero length file. This can fail e.g. on Solaris.
-rw-r--r-- | devel/nbpatch/Makefile | 4 | ||||
-rw-r--r-- | devel/nbpatch/files/inp.c | 16 |
2 files changed, 12 insertions, 8 deletions
diff --git a/devel/nbpatch/Makefile b/devel/nbpatch/Makefile index 1c3efd33862..d92dfb6c273 100644 --- a/devel/nbpatch/Makefile +++ b/devel/nbpatch/Makefile @@ -1,7 +1,7 @@ -# $NetBSD: Makefile,v 1.3 2008/09/10 19:23:31 joerg Exp $ +# $NetBSD: Makefile,v 1.4 2009/10/21 17:17:04 joerg Exp $ # -DISTNAME= nbpatch-20080910 +DISTNAME= nbpatch-20091021 CATEGORIES= devel MASTER_SITES= # empty DISTFILES= # empty diff --git a/devel/nbpatch/files/inp.c b/devel/nbpatch/files/inp.c index 349eb73e1ec..d4720be41ff 100644 --- a/devel/nbpatch/files/inp.c +++ b/devel/nbpatch/files/inp.c @@ -1,7 +1,7 @@ /* * $OpenBSD: inp.c,v 1.34 2006/03/11 19:41:30 otto Exp $ * $DragonFly: src/usr.bin/patch/inp.c,v 1.6 2007/09/29 23:11:10 swildner Exp $ - * $NetBSD: inp.c,v 1.5 2009/06/05 20:00:26 joerg Exp $ + * $NetBSD: inp.c,v 1.6 2009/10/21 17:17:04 joerg Exp $ */ /* @@ -269,12 +269,16 @@ plan_a(const char *filename) if ((ifd = open(filename, O_RDONLY)) < 0) pfatal("can't open file %s", filename); - i_womp = mmap(NULL, i_size, PROT_READ, MAP_PRIVATE, ifd, 0); - if (i_womp == MAP_FAILED) { - perror("mmap failed"); + if (i_size) { + i_womp = mmap(NULL, i_size, PROT_READ, MAP_PRIVATE, ifd, 0); + if (i_womp == MAP_FAILED) { + perror("mmap failed"); + i_womp = NULL; + close(ifd); + return false; + } + } else { i_womp = NULL; - close(ifd); - return false; } close(ifd); |