From ba5956d20221c29b8486df7c9c9701e0dba13314 Mon Sep 17 00:00:00 2001 From: Richard Russon Date: Sat, 23 Jun 2018 01:34:17 +0100 Subject: [PATCH] prepend_curdir --- recvattach.c | 26 ++++++++++++-------------- 1 file changed, 12 insertions(+), 14 deletions(-) diff --git a/recvattach.c b/recvattach.c index 717eee85b..cd98614cf 100644 --- a/recvattach.c +++ b/recvattach.c @@ -463,27 +463,25 @@ bool mutt_is_message_type(int type, const char *subtype) /** * prepend_curdir - Add './' to the beginning of a path - * @param dst Buffer for the result - * @param dstlen Size of the buffer + * @param buf Buffer for the result + * @param buflen Size of the buffer */ -static void prepend_curdir(char *dst, size_t dstlen) +static void prepend_curdir(char *buf, size_t buflen) { - size_t l; - - if (!dst || !*dst || *dst == '/' || dstlen < 3 || + if (!buf || !*buf || (*buf == '/') || (buflen < 3) || /* XXX bad modularization, these are special to mutt_expand_path() */ - !strchr("~=+@<>!-^", *dst)) + !strchr("~=+@<>!-^", *buf)) { return; } - dstlen -= 3; - l = strlen(dst) + 2; - l = (l > dstlen ? dstlen : l); - memmove(dst + 2, dst, l); - dst[0] = '.'; - dst[1] = '/'; - dst[l + 2] = 0; + buflen -= 3; + size_t l = strlen(buf) + 2; + l = (l > buflen ? buflen : l); + memmove(buf + 2, buf, l); + buf[0] = '.'; + buf[1] = '/'; + buf[l + 2] = 0; } /** -- 2.40.0