aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/vac
diff options
context:
space:
mode:
authorDavid du Colombier <0intro@gmail.com>2012-01-16 17:06:41 -0500
committerRuss Cox <rsc@swtch.com>2012-01-16 17:06:41 -0500
commit68e24566b6ba442b2bdba2dfc111c5a0d333cc42 (patch)
tree5f3bb83873ef9438004b43dadbd74953d86ba1c9 /src/cmd/vac
parent258cfab2fe5a816f23723f696c53ad6e61f6b501 (diff)
downloadplan9port-68e24566b6ba442b2bdba2dfc111c5a0d333cc42.tar.gz
plan9port-68e24566b6ba442b2bdba2dfc111c5a0d333cc42.tar.bz2
plan9port-68e24566b6ba442b2bdba2dfc111c5a0d333cc42.zip
vac: fix segfault on DMSYMLINK or DMDEVICE
Fix segfault when the first archived file is DMSYMLINK or DMDEVICE. Reinitialize the buffer to zero before calling readlink. R=rsc CC=plan9port.codebot http://codereview.appspot.com/5500097
Diffstat (limited to 'src/cmd/vac')
-rw-r--r--src/cmd/vac/vac.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/cmd/vac/vac.c b/src/cmd/vac/vac.c
index 5f896310..03ada7b9 100644
--- a/src/cmd/vac/vac.c
+++ b/src/cmd/vac/vac.c
@@ -501,12 +501,17 @@ vac(VacFile *fp, VacFile *diffp, char *name, Dir *d)
if(vacfilesetdir(f, &vd) < 0)
warn("vacfilesetdir %s: %r", name);
-
+
+ bsize = fs->bsize;
+ if(buf == nil)
+ buf = vtmallocz(bsize);
+
#ifdef PLAN9PORT
if(d->mode&(DMSOCKET|DMNAMEDPIPE)){
/* don't write anything */
}
else if(d->mode&DMSYMLINK){
+ memset(buf, 0, sizeof buf);
n = readlink(name, buf, sizeof buf);
if(n > 0 && vacfilewrite(f, buf, n, 0) < 0){
warn("venti write %s: %r", name);
@@ -539,9 +544,6 @@ vac(VacFile *fp, VacFile *diffp, char *name, Dir *d)
}
}else{
off = 0;
- bsize = fs->bsize;
- if(buf == nil)
- buf = vtmallocz(bsize);
if(fdiff){
/*
* Copy fdiff's contents into f by moving the score.