From 145e887d405fa335dc7cb045782c876f045d3b3e Mon Sep 17 00:00:00 2001 From: Ralph Boehme Date: Fri, 18 Oct 2013 17:07:41 +0200 Subject: [PATCH] Fix ressource fork name conversion Function was using ad_path() which returns a pointer to a static string twice in the rename() functions. Fixes bug #534. --- libatalk/adouble/ad_conv.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/libatalk/adouble/ad_conv.c b/libatalk/adouble/ad_conv.c index b1785c01..2a75ec62 100644 --- a/libatalk/adouble/ad_conv.c +++ b/libatalk/adouble/ad_conv.c @@ -210,6 +210,7 @@ static int ad_conv_dehex(const char *path, const struct stat *sp, const struct v static bstring str2f = NULL; static bstring strdot = NULL; static bstring strcolon = NULL; + char *newadpath = NULL; if (str2e == NULL) { str2e = bfromcstr(":2e"); @@ -231,8 +232,13 @@ static int ad_conv_dehex(const char *path, const struct stat *sp, const struct v EC_ZERO( bfindreplace(newpath, str2f, strcolon, 0) ); become_root(); - if (adflags != ADFLAGS_DIR) - rename(vol->ad_path(path, 0), vol->ad_path(bdata(newpath), 0)); + if (adflags != ADFLAGS_DIR) { + if ((newadpath = strdup(vol->ad_path(bdata(newpath), 0))) == NULL) { + unbecome_root(); + EC_FAIL; + } + rename(vol->ad_path(path, 0), newadpath); + } rename(path, bdata(newpath)); unbecome_root(); @@ -242,6 +248,8 @@ static int ad_conv_dehex(const char *path, const struct stat *sp, const struct v EC_CLEANUP: if (newpath) bdestroy(newpath); + if (newadpath) + free(newadpath); EC_EXIT; } -- 2.39.2