retitle 430387 [PATCH] `fcrackzip --use-unzip' cannot deal with file names containing a single quote tags 430387 + patch thanks
See attached patch to canonicalize special charcters in filenames. Hope this or similar treatment could be included in next release. Jari Aalto
>From f681ef1c9feee2833f4e62aa7b9d8c74595a14d8 Mon Sep 17 00:00:00 2001 From: Jari Aalto <[email protected]> Date: Tue, 5 Jan 2010 20:06:17 +0200 Subject: [PATCH] main.c: (path_for_shell): handle special file names Signed-off-by: Jari Aalto <[email protected]> --- main.c | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 59 insertions(+), 1 deletions(-) diff --git a/main.c b/main.c index f632241..1de75e6 100644 --- a/main.c +++ b/main.c @@ -44,13 +44,71 @@ static int modul = 1; static FILE *dict_file; +char * +path_for_shell (char *dest, const char *str) +{ + /* backslash shell special charatcers */ + + char ch, *p = dest; + size_t len = strlen(str); + int i; + + for (i = 0; i < len; i++) + { + ch = str[i]; + + switch (ch) + { + /* ASCII table order */ + case '!': + case '"': + case '#': + case '$': + case '&': + case 0x27: /* single quote */ + case '(': + case ')': + case '*': + case '+': + case 0x2C: + case ':': + case ';': + case '<': + case '>': + case '?': + case '[': + case '\\': + case ']': + case '^': + case '`': + case '{': + case '|': + case '}': + /* backslash special characters */ + *p++ = '\\'; + *p++ = ch; + break; + default: + *p++ = ch; + } + } + + /* terminate string */ + *p = '\0'; + + return dest; +} + int REGPARAM check_unzip (const char *pw) { char buff[1024]; + char path[1024]; int status; - sprintf (buff, "unzip -qqtP \"%s\" %s " DEVNULL, pw, file_path[0]); + path_for_shell (path, file_path[0]); + + sprintf (buff, "unzip -qqtP \"%s\" %s " DEVNULL, pw, path); status = system (buff); #undef REDIR -- 1.6.5

