From: Fabian Groffen Date: Thu, 10 Jan 2019 15:03:02 +0000 (+0100) Subject: mx_open_mailbox: provide output buffer to realpath(3) X-Git-Tag: mutt-1-11-3-rel~10 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=42101583f62b8b9a7976b30002b6648c74d223a2;p=mutt mx_open_mailbox: provide output buffer to realpath(3) 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 --- diff --git a/mx.c b/mx.c index 9d311ef8..8b150bd0 100644 --- 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;