View | Details | Raw Unified | Return to bug 2580
Collapse All | Expand All

(-)src/lib/libc/gen/glob.c.new (-6 / +8 lines)
Lines 142-148 Link Here
142
static int	 glob2 __P((Char *, Char *, Char *, glob_t *));
142
static int	 glob2 __P((Char *, Char *, Char *, glob_t *));
143
static int	 glob3 __P((Char *, Char *, Char *, Char *, glob_t *));
143
static int	 glob3 __P((Char *, Char *, Char *, Char *, glob_t *));
144
static int	 globextend __P((const Char *, glob_t *));
144
static int	 globextend __P((const Char *, glob_t *));
145
static const Char *	 globtilde __P((const Char *, Char *, glob_t *));
145
static const Char *	 globtilde __P((const Char *, Char *, int, glob_t *));
146
static int	 globexp1 __P((const Char *, glob_t *));
146
static int	 globexp1 __P((const Char *, glob_t *));
147
static int	 globexp2 __P((const Char *, const Char *, glob_t *, int *));
147
static int	 globexp2 __P((const Char *, const Char *, glob_t *, int *));
148
static int	 match __P((Char *, Char *, Char *));
148
static int	 match __P((Char *, Char *, Char *));
Lines 332-352 Link Here
332
 * expand tilde from the passwd file.
332
 * expand tilde from the passwd file.
333
 */
333
 */
334
static const Char *
334
static const Char *
335
globtilde(pattern, patbuf, pglob)
335
globtilde(pattern, patbuf, len, pglob)
336
	const Char *pattern;
336
	const Char *pattern;
337
	Char *patbuf;
337
	Char *patbuf;
338
	int len;
338
	glob_t *pglob;
339
	glob_t *pglob;
339
{
340
{
340
	struct passwd *pwd;
341
	struct passwd *pwd;
341
	char *h;
342
	char *h;
342
	const Char *p;
343
	const Char *p;
343
	Char *b;
344
	Char *b;
345
	int l;
344
346
345
	if (*pattern != TILDE || !(pglob->gl_flags & GLOB_TILDE))
347
	if (*pattern != TILDE || !(pglob->gl_flags & GLOB_TILDE))
346
		return pattern;
348
		return pattern;
347
349
348
	/* Copy up to the end of the string or / */
350
	/* Copy up to the end of the string or / */
349
	for (p = pattern + 1, h = (char *) patbuf; *p && *p != SLASH;
351
	for (l = len, p = pattern + 1, h = (char *) patbuf; *p && *p != SLASH && l-- >0;
350
	     *h++ = *p++)
352
	     *h++ = *p++)
351
		continue;
353
		continue;
352
354
Lines 375-385 Link Here
375
	}
377
	}
376
378
377
	/* Copy the home directory */
379
	/* Copy the home directory */
378
	for (b = patbuf; *h; *b++ = *h++)
380
	for (l = len, b = patbuf; *h && l-- >0; *b++ = *h++)
379
		continue;
381
		continue;
380
382
381
	/* Append the rest of the pattern */
383
	/* Append the rest of the pattern */
382
	while ((*b++ = *p++) != EOS)
384
	while (l-- >0 && (*b++ = *p++) != EOS)
383
		continue;
385
		continue;
384
386
385
	return patbuf;
387
	return patbuf;
Lines 402-408 Link Here
402
	int c, err, oldpathc;
404
	int c, err, oldpathc;
403
	Char *bufnext, patbuf[MAXPATHLEN+1];
405
	Char *bufnext, patbuf[MAXPATHLEN+1];
404
406
405
	qpatnext = globtilde(pattern, patbuf, pglob);
407
	qpatnext = globtilde(pattern, patbuf, sizeof patbuf, pglob);
406
	oldpathc = pglob->gl_pathc;
408
	oldpathc = pglob->gl_pathc;
407
	bufnext = patbuf;
409
	bufnext = patbuf;

Return to bug 2580