summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--usr.bin/diff/diffreg.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/usr.bin/diff/diffreg.c b/usr.bin/diff/diffreg.c
index 328ce07dddd..80907aa5554 100644
--- a/usr.bin/diff/diffreg.c
+++ b/usr.bin/diff/diffreg.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: diffreg.c,v 1.80 2011/04/01 17:25:26 nicm Exp $ */
+/* $OpenBSD: diffreg.c,v 1.81 2012/05/22 12:30:24 millert Exp $ */
/*
* Copyright (C) Caldera International Inc. 2001-2002.
@@ -536,12 +536,16 @@ char *
splice(char *dir, char *file)
{
char *tail, *buf;
+ size_t dirlen;
+ dirlen = strlen(dir);
+ while (dirlen != 0 && dir[dirlen - 1] == '/')
+ dirlen--;
if ((tail = strrchr(file, '/')) == NULL)
tail = file;
else
tail++;
- xasprintf(&buf, "%s/%s", dir, tail);
+ xasprintf(&buf, "%.*s/%s", (int)dirlen, dir, tail);
return (buf);
}