Wed Jul 22 18:25:26 2009 UTC ()
Only need path if we have issetugid... From Anon Ymous


(christos)
diff -r1.53 -r1.54 src/lib/libedit/el.c

cvs diff -r1.53 -r1.54 src/lib/libedit/el.c (expand / switch to unified diff)

--- src/lib/libedit/el.c 2009/07/22 15:56:29 1.53
+++ src/lib/libedit/el.c 2009/07/22 18:25:26 1.54
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: el.c,v 1.53 2009/07/22 15:56:29 christos Exp $ */ 1/* $NetBSD: el.c,v 1.54 2009/07/22 18:25:26 christos Exp $ */
2 2
3/*- 3/*-
4 * Copyright (c) 1992, 1993 4 * Copyright (c) 1992, 1993
5 * The Regents of the University of California. All rights reserved. 5 * The Regents of the University of California. All rights reserved.
6 * 6 *
7 * This code is derived from software contributed to Berkeley by 7 * This code is derived from software contributed to Berkeley by
8 * Christos Zoulas of Cornell University. 8 * Christos Zoulas of Cornell University.
9 * 9 *
10 * Redistribution and use in source and binary forms, with or without 10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions 11 * modification, are permitted provided that the following conditions
12 * are met: 12 * are met:
13 * 1. Redistributions of source code must retain the above copyright 13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer. 14 * notice, this list of conditions and the following disclaimer.
@@ -27,27 +27,27 @@ @@ -27,27 +27,27 @@
27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 * SUCH DAMAGE. 32 * SUCH DAMAGE.
33 */ 33 */
34 34
35#include "config.h" 35#include "config.h"
36#if !defined(lint) && !defined(SCCSID) 36#if !defined(lint) && !defined(SCCSID)
37#if 0 37#if 0
38static char sccsid[] = "@(#)el.c 8.2 (Berkeley) 1/3/94"; 38static char sccsid[] = "@(#)el.c 8.2 (Berkeley) 1/3/94";
39#else 39#else
40__RCSID("$NetBSD: el.c,v 1.53 2009/07/22 15:56:29 christos Exp $"); 40__RCSID("$NetBSD: el.c,v 1.54 2009/07/22 18:25:26 christos Exp $");
41#endif 41#endif
42#endif /* not lint && not SCCSID */ 42#endif /* not lint && not SCCSID */
43 43
44/* 44/*
45 * el.c: EditLine interface functions 45 * el.c: EditLine interface functions
46 */ 46 */
47#include <sys/types.h> 47#include <sys/types.h>
48#include <sys/param.h> 48#include <sys/param.h>
49#include <string.h> 49#include <string.h>
50#include <stdlib.h> 50#include <stdlib.h>
51#include <stdarg.h> 51#include <stdarg.h>
52#include "el.h" 52#include "el.h"
53 53
@@ -482,27 +482,29 @@ el_line(EditLine *el) @@ -482,27 +482,29 @@ el_line(EditLine *el)
482 return (const LineInfo *) (void *) &el->el_line; 482 return (const LineInfo *) (void *) &el->el_line;
483} 483}
484 484
485 485
486/* el_source(): 486/* el_source():
487 * Source a file 487 * Source a file
488 */ 488 */
489public int 489public int
490el_source(EditLine *el, const char *fname) 490el_source(EditLine *el, const char *fname)
491{ 491{
492 FILE *fp; 492 FILE *fp;
493 size_t len; 493 size_t len;
494 char *ptr; 494 char *ptr;
 495#ifdef HAVE_ISSETUGID
495 char path[MAXPATHLEN]; 496 char path[MAXPATHLEN];
 497#endif
496 498
497 fp = NULL; 499 fp = NULL;
498 if (fname == NULL) { 500 if (fname == NULL) {
499#ifdef HAVE_ISSETUGID 501#ifdef HAVE_ISSETUGID
500 static const char elpath[] = "/.editrc"; 502 static const char elpath[] = "/.editrc";
501 503
502 if (issetugid()) 504 if (issetugid())
503 return (-1); 505 return (-1);
504 if ((ptr = getenv("HOME")) == NULL) 506 if ((ptr = getenv("HOME")) == NULL)
505 return (-1); 507 return (-1);
506 if (strlcpy(path, ptr, sizeof(path)) >= sizeof(path)) 508 if (strlcpy(path, ptr, sizeof(path)) >= sizeof(path))
507 return (-1); 509 return (-1);
508 if (strlcat(path, elpath, sizeof(path)) >= sizeof(path)) 510 if (strlcat(path, elpath, sizeof(path)) >= sizeof(path))