]> git.puffer.fish Git - mirror/frr.git/commitdiff
2003-10-15 Paul Jakma <paul@dishone.st>
authorpaul <paul>
Wed, 15 Oct 2003 22:09:28 +0000 (22:09 +0000)
committerpaul <paul>
Wed, 15 Oct 2003 22:09:28 +0000 (22:09 +0000)
* lib/vty.c: (vty_save_cwd) dont crash if getcwd fails. try fallback
          to SYSCONFDIR. Allocate cwd from the stack rather than relying on
          (non-portable) getcwd() allocation (which we didnt seem to be
  freeing).

lib/vty.c

index 90e1dadb5b6c8b8f99323349675e17fd60bb4882..4e341bf1972559344e042df89616b4565a973155 100644 (file)
--- a/lib/vty.c
+++ b/lib/vty.c
@@ -2757,9 +2757,15 @@ vty_finish ()
 void
 vty_save_cwd ()
 {
-  char *cwd;
+  char cwd[MAXPATHLEN];
+
+  cwd[0] = getcwd (cwd, MAXPATHLEN);
 
-  cwd = getcwd (NULL, MAXPATHLEN);
+  if (!cwd)
+    {
+      chdir (SYSCONFDIR);
+      cwd[0] = getcwd (cwd, MAXPATHLEN);
+    }
 
   vty_cwd = XMALLOC (MTYPE_TMP, strlen (cwd) + 1);
   strcpy (vty_cwd, cwd);