Path: blob/main/security/fcrackzip/files/patch-main.c
16155 views
--- main.c.orig 2005-09-10 19:58:44 UTC1+++ main.c2@@ -44,13 +44,112 @@ static int modul = 1;34static FILE *dict_file;56+char *7+path_for_shell (char *dest, const char *str)8+{9+ /* backslash shell special charatcers */10+11+ char ch, *p = dest;12+ size_t len = strlen(str);13+ int i;14+15+ for (i = 0; i < len; i++)16+ {17+ ch = str[i];18+19+ switch (ch)20+ {21+ /* ASCII table order */22+ case 0x20: /* space */23+ case '!':24+ case '"':25+ case '#':26+ case '$':27+ case '&':28+ case 0x27: /* single quote */29+ case '(':30+ case ')':31+ case '*':32+ case '+':33+ case 0x2C: /* comma */34+ case ':':35+ case ';':36+ case '<':37+ case '>':38+ case '?':39+ case '[':40+ case '\\':41+ case ']':42+ case '^':43+ case '`':44+ case '{':45+ case '|':46+ case '}':47+ case '~':48+ /* backslash special characters */49+ *p++ = '\\';50+ *p++ = ch;51+ break;52+ default:53+ *p++ = ch;54+ }55+ }56+57+ /* terminate string */58+ *p = '\0';59+60+ return dest;61+}62+63+char *64+escape_pw (char *dest, const char *str)65+{66+ /* backslash shell special charatcers */67+68+ char ch, *p = dest;69+ size_t len = strlen(str);70+ int i;71+72+ for (i = 0; i < len; i++)73+ {74+ ch = str[i];75+76+ switch (ch)77+ {78+ /* ASCII table order */79+ case '"':80+ case '$':81+ case 0x27: /* single quote */82+ case '\\':83+ case '`':84+ /* backslash special characters */85+ *p++ = '\\';86+ *p++ = ch;87+ break;88+ default:89+ *p++ = ch;90+ }91+ }92+93+ /* terminate string */94+ *p = '\0';95+96+ return dest;97+}98+99int REGPARAM100check_unzip (const char *pw)101{102char buff[1024];103+ char path[1024];104+ char escpw[256];105int status;106107- sprintf (buff, "unzip -qqtP \"%s\" %s " DEVNULL, pw, file_path[0]);108+ escape_pw (escpw, pw);109+ path_for_shell (path, file_path[0]);110+111+ sprintf (buff, "unzip -qqtP \"%s\" %s " DEVNULL, escpw, path);112+113status = system (buff);114115#undef REDIR116117118