From 4bb9faaf50654d375a0e6a0410382722695277d9 Mon Sep 17 00:00:00 2001 From: Katerina Blinova Date: Thu, 27 Jun 2013 11:46:52 -0700 Subject: [PATCH 1/2] Detect Window's style slashes in mg_upload file names --- mongoose.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/mongoose.c b/mongoose.c index 1293836b..762b9091 100644 --- a/mongoose.c +++ b/mongoose.c @@ -4227,8 +4227,11 @@ int mg_upload(struct mg_connection *conn, const char *destination_dir) { fp = NULL; // Construct destination file name. Do not allow paths to have slashes. if ((s = strrchr(fname, '/')) == NULL) { - s = fname; + if ((s = strrchr(fname, '\\')) == NULL) { + s = fname; + } } + // Open file in binary mode. TODO: set an exclusive lock. snprintf(path, sizeof(path), "%s/%s", destination_dir, s); if ((fp = fopen(path, "wb")) == NULL) { From dfb7d928c2f098103572c9b76fbbfcdbb7f54364 Mon Sep 17 00:00:00 2001 From: Katerina Blinova Date: Fri, 28 Jun 2013 11:05:33 -0700 Subject: [PATCH 2/2] Review revision for windows path separator detection in mg_upload --- mongoose.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/mongoose.c b/mongoose.c index 762b9091..348db9a9 100644 --- a/mongoose.c +++ b/mongoose.c @@ -4226,10 +4226,9 @@ int mg_upload(struct mg_connection *conn, const char *destination_dir) { // there is no other thread can save into the same file simultaneously. fp = NULL; // Construct destination file name. Do not allow paths to have slashes. - if ((s = strrchr(fname, '/')) == NULL) { - if ((s = strrchr(fname, '\\')) == NULL) { + if ((s = strrchr(fname, '/')) == NULL && + (s = strrchr(fname, '\\')) == NULL) { s = fname; - } } // Open file in binary mode. TODO: set an exclusive lock.