Module Name: src Committed By: christos Date: Wed Aug 28 08:05:21 UTC 2013
Modified Files: src/lib/libedit: readline.c Log Message: get rid of PATH_MAX. To generate a diff of this commit: cvs rdiff -u -r1.108 -r1.109 src/lib/libedit/readline.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/lib/libedit/readline.c diff -u src/lib/libedit/readline.c:1.108 src/lib/libedit/readline.c:1.109 --- src/lib/libedit/readline.c:1.108 Mon May 27 20:10:34 2013 +++ src/lib/libedit/readline.c Wed Aug 28 04:05:21 2013 @@ -1,4 +1,4 @@ -/* $NetBSD: readline.c,v 1.108 2013/05/28 00:10:34 christos Exp $ */ +/* $NetBSD: readline.c,v 1.109 2013/08/28 08:05:21 christos Exp $ */ /*- * Copyright (c) 1997 The NetBSD Foundation, Inc. @@ -31,7 +31,7 @@ #include "config.h" #if !defined(lint) && !defined(SCCSID) -__RCSID("$NetBSD: readline.c,v 1.108 2013/05/28 00:10:34 christos Exp $"); +__RCSID("$NetBSD: readline.c,v 1.109 2013/08/28 08:05:21 christos Exp $"); #endif /* not lint && not SCCSID */ #include <sys/types.h> @@ -236,13 +236,20 @@ static const char * _default_history_file(void) { struct passwd *p; - static char path[PATH_MAX]; + static char *path; + size_t len; - if (*path) + if (path) return path; + if ((p = getpwuid(getuid())) == NULL) return NULL; - (void)snprintf(path, sizeof(path), "%s/.history", p->pw_dir); + + len = strlen(p->pw_dir) + sizeof("/.history"); + if ((path = malloc(len)) == NULL) + return NULL; + + (void)snprintf(path, len, "%s/.history", p->pw_dir); return path; }