From ccc9235e602ebd578fbeba3c98499b3933069d96 Mon Sep 17 00:00:00 2001 From: paul Date: Wed, 22 Oct 2003 02:49:38 +0000 Subject: 2003-10-22 Paul Jakma * lib/vty.c: cleanup getcwd again. just pass the buffer in to getcwd. --- lib/vty.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/vty.c b/lib/vty.c index 1c249122..deae16e3 100644 --- a/lib/vty.c +++ b/lib/vty.c @@ -2202,7 +2202,7 @@ vty_read_config (char *config_file, char *config_current_dir, char *config_default_dir) { - char *cwd; + char cwd[MAXPATHLEN]; FILE *confp = NULL; char *fullpath; @@ -2211,7 +2211,7 @@ vty_read_config (char *config_file, { if (! IS_DIRECTORY_SEP (config_file[0])) { - cwd = getcwd (NULL, MAXPATHLEN); + getcwd (cwd, MAXPATHLEN); fullpath = XMALLOC (MTYPE_TMP, strlen (cwd) + strlen (config_file) + 2); sprintf (fullpath, "%s/%s", cwd, config_file); @@ -2299,7 +2299,7 @@ vty_read_config (char *config_file, else { /* Rleative path configuration file. */ - cwd = getcwd (NULL, MAXPATHLEN); + getcwd (cwd, MAXPATHLEN); fullpath = XMALLOC (MTYPE_TMP, strlen (cwd) + strlen (config_current_dir) + 2); sprintf (fullpath, "%s/%s", cwd, config_current_dir); @@ -2763,13 +2763,14 @@ void vty_save_cwd () { char cwd[MAXPATHLEN]; + char *c; - cwd[0] = getcwd (cwd, MAXPATHLEN); + c = getcwd (cwd, MAXPATHLEN); - if (!cwd) + if (!c) { chdir (SYSCONFDIR); - cwd[0] = getcwd (cwd, MAXPATHLEN); + getcwd (cwd, MAXPATHLEN); } vty_cwd = XMALLOC (MTYPE_TMP, strlen (cwd) + 1); -- cgit v1.2.1