]> granicus.if.org Git - mutt/commitdiff
mx_open_mailbox: provide output buffer to realpath(3)
authorFabian Groffen <grobian@gentoo.org>
Thu, 10 Jan 2019 15:03:02 +0000 (16:03 +0100)
committerFabian Groffen <grobian@gentoo.org>
Thu, 10 Jan 2019 15:03:02 +0000 (16:03 +0100)
Starting with POSIX.1.2008 resolved_path can be NULL.
Systems implementing a standard before that crash.  Example of such
system is Mac OS X 10.5, the last version running on PowerPC hardware.

Since this is the only occurrance of the realpath(3) function in Mutt,
instead of wrapping it, just adjust this invocation.

Signed-off-by: Fabian Groffen <grobian@gentoo.org>
mx.c

diff --git a/mx.c b/mx.c
index 9d311ef81277b39d95a5ac161a77073be3f4cbf3..8b150bd0624f42fa77414f6573b722ee3c1da7c8 100644 (file)
--- a/mx.c
+++ b/mx.c
@@ -573,6 +573,7 @@ CONTEXT *mx_open_mailbox (const char *path, int flags, CONTEXT *pctx)
 {
   CONTEXT *ctx = pctx;
   int rc;
+  char realpathbuf[PATH_MAX];
 
   if (!ctx)
     ctx = safe_malloc (sizeof (CONTEXT));
@@ -585,8 +586,10 @@ CONTEXT *mx_open_mailbox (const char *path, int flags, CONTEXT *pctx)
       FREE (&ctx);
     return NULL;
   }
-  if (! (ctx->realpath = realpath (ctx->path, NULL)) )
+  if (! realpath (ctx->path, realpathbuf) )
     ctx->realpath = safe_strdup (ctx->path);
+  else
+    ctx->realpath = safe_strdup (realpathbuf);
 
   ctx->msgnotreadyet = -1;
   ctx->collapsed = 0;