fix bugs in the previous. use snprintf(). fixes the problem reported
in PR#25131.
This commit is contained in:
parent
8af58b1851
commit
fa97f05587
@ -1,4 +1,4 @@
|
|||||||
/* $NetBSD: tar.c,v 1.48 2004/04/01 14:54:39 mrg Exp $ */
|
/* $NetBSD: tar.c,v 1.49 2004/04/12 14:41:09 mrg Exp $ */
|
||||||
|
|
||||||
/*-
|
/*-
|
||||||
* Copyright (c) 1992 Keith Muller.
|
* Copyright (c) 1992 Keith Muller.
|
||||||
@ -42,7 +42,7 @@
|
|||||||
#if 0
|
#if 0
|
||||||
static char sccsid[] = "@(#)tar.c 8.2 (Berkeley) 4/18/94";
|
static char sccsid[] = "@(#)tar.c 8.2 (Berkeley) 4/18/94";
|
||||||
#else
|
#else
|
||||||
__RCSID("$NetBSD: tar.c,v 1.48 2004/04/01 14:54:39 mrg Exp $");
|
__RCSID("$NetBSD: tar.c,v 1.49 2004/04/12 14:41:09 mrg Exp $");
|
||||||
#endif
|
#endif
|
||||||
#endif /* not lint */
|
#endif /* not lint */
|
||||||
|
|
||||||
@ -1265,14 +1265,16 @@ name_split(char *name, int len)
|
|||||||
static int
|
static int
|
||||||
tar_gnutar_exclude_one(const char *line, size_t len)
|
tar_gnutar_exclude_one(const char *line, size_t len)
|
||||||
{
|
{
|
||||||
/* 2* buffer len + 5 prefix + 5 postfix + null subst + nul */
|
/* 2 * buffer len + nul */
|
||||||
char sbuf[MAXPATHLEN * 2 + 4 + 4 + 5 + 1];
|
char sbuf[MAXPATHLEN * 2 + 1];
|
||||||
|
/* + / + // + .*""/\/ + \/.* */
|
||||||
|
char rabuf[MAXPATHLEN * 2 + 1 + 1 + 2 + 4 + 4];
|
||||||
int i, j;
|
int i, j;
|
||||||
|
|
||||||
if (line[len - 1] == '\n')
|
if (line[len - 1] == '\n')
|
||||||
len--;
|
len--;
|
||||||
strncpy(sbuf, ".*" "\\/", 4);
|
strncpy(sbuf, ".*" "\\/", j = 4);
|
||||||
for (i = 0, j = 4; i < len; i++) {
|
for (i = 0; i < len; i++) {
|
||||||
/*
|
/*
|
||||||
* convert glob to regexp, escaping everything
|
* convert glob to regexp, escaping everything
|
||||||
*/
|
*/
|
||||||
@ -1285,18 +1287,21 @@ tar_gnutar_exclude_one(const char *line, size_t len)
|
|||||||
sbuf[j++] = '\\';
|
sbuf[j++] = '\\';
|
||||||
sbuf[j++] = line[i];
|
sbuf[j++] = line[i];
|
||||||
}
|
}
|
||||||
strncpy(&sbuf[j], "$", 2);
|
/* don't need the .*\/ ones if we start with /, i guess */
|
||||||
if (rep_add(sbuf) < 0)
|
if (line[0] != '/') {
|
||||||
return (-1);
|
snprintf(rabuf, sizeof rabuf, "/.*\\/%s$//", sbuf);
|
||||||
strncpy(&sbuf[j], "\\/.*", 5);
|
if (rep_add(rabuf) < 0)
|
||||||
if (rep_add(sbuf) < 0)
|
return (-1);
|
||||||
return (-1);
|
snprintf(rabuf, sizeof rabuf, "/.*\\/%s\\/.*//", sbuf);
|
||||||
|
if (rep_add(rabuf) < 0)
|
||||||
|
return (-1);
|
||||||
|
}
|
||||||
|
|
||||||
sbuf[3] = '^';
|
snprintf(rabuf, sizeof rabuf, "/^%s$//", sbuf);
|
||||||
if (rep_add(sbuf+3) < 0)
|
if (rep_add(rabuf) < 0)
|
||||||
return (-1);
|
return (-1);
|
||||||
strncpy(&sbuf[j], "$", 2);
|
snprintf(rabuf, sizeof rabuf, "/^%s\\/.*//", sbuf);
|
||||||
if (rep_add(sbuf+3) < 0)
|
if (rep_add(rabuf) < 0)
|
||||||
return (-1);
|
return (-1);
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
|
Loading…
Reference in New Issue
Block a user