From a069ee520ab1e7f6725192c3d453ff8b5397e9c5 Mon Sep 17 00:00:00 2001 From: Nils Durner Date: Sat, 27 Aug 2005 18:28:55 +0000 Subject: - don't exceed MAX_PATH under Windows --- src/plugins/fs/download.c | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/src/plugins/fs/download.c b/src/plugins/fs/download.c index 36cc5d65..2fd3e2b9 100644 --- a/src/plugins/fs/download.c +++ b/src/plugins/fs/download.c @@ -199,9 +199,25 @@ static void initiateDownload(GtkTreeModel * model, DIR_SEPARATOR_STR); strcat(pfx, name); +#ifndef WINDOWS strcat(lnk, &filename[strlen(ECRS_URI_PREFIX) + strlen(ECRS_FILE_INFIX)]); +#else + { + /* Do not exceed MAX_PATH under Windows */ + + int fnlen = MAX_PATH - strlen(lnk) - 4; /* 4 = ".lnk"*/ + if (fnlen < 4) { + BREAK(); + return; + } + + strncat(lnk, + &filename[strlen(ECRS_URI_PREFIX) + + strlen(ECRS_FILE_INFIX)], fnlen); + } +#endif if (0 != STAT(pfx, &sbuf)) { if (0 != SYMLINK(lnk, pfx)) @@ -371,14 +387,13 @@ void displayDownloadComplete(const struct ECRS_URI * uri, ren = ECRS_suggestFilename(ln); newFn = strrchr(ren ? ren : ln, DIR_SEPARATOR) + 1; - dstPath = getConfigurationString("FS", "INCOMINGDIR"); - if (!dstPath) { - LOG(LOG_ERROR, - _("You must specify a directory in the configuration" - " in section `%s' under `%s'.\n"), "FS", "INCOMINGDIR"); - + + dstPath = getFileName("FS", + "INCOMINGDIR", + _("You must specify a directory in the configuration" + " in section `%s' under `%s'.")); + if (!dstPath) return; - } mkdirp(dstPath); dstFile = MALLOC(strlen(dstPath) + strlen(newFn) + 2); -- cgit v1.2.3