/* * This file contains the currently coding style problems in john jumbo * */ /* * ProblemID: 1 * ERROR: space prohibited after that '-' (ctx:WxW) * #200: FILE: john_the_ripper/src/rar2john.c:200: * + jtr_fseek64(fp, - diff, SEEK_CUR); * ^ */ static void process_file(const char *archive_name) { jtr_fseek64(fp, - diff, SEEK_CUR); } /* * ProblemID: 2 * ERROR: space required one side of that '--' (ctx:WxW) * #183: FILE: john_the_ripper/src/panama_plug.c:183: * + while (num -- > 0) { * ^ */ static void panama_push(void) { while (num -- > 0) { do_something(); do_something(); } } /* * ProblemID: 3 * ERROR: spaces prohibited around that '->' (ctx:WxV) * #450: FILE: john_the_ripper/src/opencl_DES_bs_b_plug.c:450: * + num_loaded_hashes_salt[current_salt] = salt ->count; * ^ */ static int des_crypt_25(int *pcount, struct db_salt *salt) { num_loaded_hashes_salt[current_salt] = salt ->count; return 32 * cmp_out[0]; } /* * ProblemID: 4 * ERROR: space required before the open brace '{' * #110: FILE: john_the_ripper/src/keychain2john.c:110: * + if(bytes != SALTLEN){ */ void function(void) { if(bytes != SALTLEN){ fprintf(stderr, "Something went wrong - fread(salt) error\n"); exit(1); } } /* * ProblemID: 5 * ERROR: space prohibited before that ',' (ctx:WxV) * #181: FILE: john_the_ripper/src/encfs_fmt_plug.c:181: * + encfs_common_streamDecode(cur_salt, tmpBuf, * cur_salt->keySize + cur_salt->ivLength ,checksum, master[j]); * ^ */ void function(void) { encfs_common_streamDecode(cur_salt, tmpBuf, cur_salt->keySize + cur_salt->ivLength ,checksum, master[j]); } /* * ProblemID: 6 * ERROR: space required before the open parenthesis '(' * #131: FILE: john_the_ripper/src/7z_fmt_plug.c:131: * + if(len > 16 || len < 0) */ void function(void) { if(len > 16 || len < 0) goto err; } /* * ProblemID: 7 * ERROR: trailing whitespace * #1: FILE: john_the_ripper/src/cryptmd5_common_plug.c:1: * +/* $ */ void function(void) { /* * The line before this line has a blank */ } /* * ProblemID: 8 * ERROR: need consistent spacing around '/' (ctx:WxV) * #357: FILE: john_the_ripper/src/wordlist.c:357: * + fprintf (stderr, "pos="LLd" size="LLd" percent=%0.4f\n", * (long long)pos, (long long)size, * (100.0 * ((rule_number * (double)size) + pos) /(rule_count * (double)size))); * ^ */ void function(void) { fprintf (stderr, "pos="LLd" size="LLd" percent=%0.4f\n", (long long)pos, (long long)size, (100.0 * ((rule_number * (double)size) + pos) /(rule_count * (double)size))); } /* * ProblemID: 9 * ERROR: open brace '{' following enum go on the same line * #81: FILE: john_the_ripper/src/keepass2john.c:81: * +enum Kdb4HeaderFieldID * +{ */ enum Kdb4HeaderFieldID { EndOfHeader = 0, MasterSeed = 4, }; /* * ProblemID: 10 * ERROR: while should follow close brace '}' * #2942: FILE: john_the_ripper/src/dynamic_fmt.c:2942: * + } * + while (--w32_cnt); */ void function(void) { do { do_something(); do_something(); } while (--w32_cnt); } /* * ProblemID: 11 * ERROR: that open brace { should be on the previous line * #296: FILE: john_the_ripper/src/aix_ssha_fmt_plug.c:296: * + for (index = 0; index < count; index += MAX_KEYS_PER_CRYPT) * + { */ void function(void) { for (index = 0; index < count; index += MAX_KEYS_PER_CRYPT) { do_something(); do_something(); } } /* * ProblemID: 12 * ERROR: open brace '{' following function declarations go on the next line * #179: FILE: john_the_ripper/src/aix_ssha_fmt_plug.c:179: * + static int valid_sha1(char *ciphertext, struct fmt_main *self) { */ void function(void) { do_something(); } /* * ProblemID: 13 * ERROR: else should follow close brace '}' * #130: FILE: john_the_ripper/src/aix_smd5_fmt_plug.c:130: * + } * + else { */ void function(void) { if (!strncmp(ciphertext, "{smd5}", 6)) { ctcopy += 6; cs.is_standard = 0; } else { ctcopy += 3; cs.is_standard = 1; } } /* * ProblemID: 14 * ERROR: code indent should use tabs where possible * #94: FILE: john_the_ripper/src/7z_fmt_plug.c:94: * +^I sizeof(*saved_key));$ */ void function(void) { saved_key = mem_calloc(self->params.max_keys_per_crypt, sizeof(*saved_key)); } /* * ProblemID: 15 * ERROR: switch and case should be at the same indent * #132: FILE: john_the_ripper/src/base64_convert.c:132: * + switch (mod) { * + case 0: * [...] * + case 1: * [...] * + case 2: */ void function(void) { switch (mod) { case 0: enc_base64_1_iBS(outy, u, 4); outy[4] = 0; break; case 1: enc_base64_1_iBS(outy, u, 2); outy[2] = 0; break; case 2: enc_base64_1_iBS(outy, u, 3); outy[3] = 0; break; } } /* * ProblemID: 16 * ERROR: "foo*bar" should be "foo *bar" * #93: FILE: john_the_ripper/src/common-gpu.c:93: * + void*lpBuffer = malloc(iSize); */ void function(void) { void*lpBuffer = malloc(iSize); } /* * ProblemID: 17 * ERROR: trailing statements should be on next line * #130: FILE: john_the_ripper/src/AFS_fmt.c:130: * + if (strncmp(ciphertext, "$K4$", 4)) return 0; */ void function(void) { if (strncmp(ciphertext, "$K4$", 4)) return 0; } /* * ProblemID: 18 * WARNING: please, no space before tabs * #53: FILE: john_the_ripper/src/7z_fmt_plug.c:53: * +#define BIG_ENOUGH ^I^I(8192 * 32)$ */ #define BIG_ENOUGH (8192 * 32) /* * ProblemID: 19 * WARNING: Unnecessary space before function pointer arguments * #85: FILE: john_the_ripper/src/plugin.c:85: * + struct fmt_main *(*loader) (int fmt_version); */ void function(void) { struct fmt_main *(*loader) (int fmt_version); } /* * ProblemID: 20 * WARNING: space prohibited before semicolon * #108: FILE: john_the_ripper/src/BF_common_plug.c:108: * + unsigned char *dptr = (unsigned char *)dst ; */ void function(void) { unsigned char *dptr = (unsigned char *)dst ; } /* * ProblemID: 21 * WARNING: please, no spaces at the start of a line * #333: FILE: john_the_ripper/src/7z_fmt_plug.c:333: * + SHA256_Init(&sha);$ */ void function(void) { /* kdf */ SHA256_Init(&sha); } /* * ProblemID: 22 * WARNING: labels should not be indented * #2565: FILE: john_the_ripper/src/gpg2john.c:2565: * + again: */ void function(void) { if (found == NO) { again: found = YES; } } /* * ProblemID: 23 * WARNING: trailing semicolon indicates no statements, indent implies otherwise * #1590: FILE: john_the_ripper/src/gpg2john.c:1590: * + if (Getc() == 0); * + // printf("No"); */ void function(void) { if (Getc() == 0); // printf("No"); else; // printf("Yes"); // printf("\n"); } /* * ProblemID: 24 * WARNING: suspect code indent for conditional statements (2, 4) * #15: FILE: john_the_ripper/src/base64.c:15: * + for(i=0; i<4; i++) { * + c = in_block + i; */ void function(void) { for(i=0; i<4; i++) { c = in_block + i; *c = 0; } } /* * ProblemID: 25 * WARNING: Missing a blank line after declarations * #360: FILE: john_the_ripper/src/7z_fmt_plug.c:360: * + unsigned char master[32]; * + sevenzip_kdf((unsigned char*)saved_key[index], master); */ void function(void) { unsigned char master[32]; sevenzip_kdf((unsigned char*)saved_key[index], master); } /* * Prolems can not be solved by tools */ /* * ProblemID: 26 * WARNING: space prohibited between function name and open parenthesis '(' * #85: FILE: john_the_ripper/src/7z_fmt_plug.c:85: * +#if defined (_OPENMP) */ void function(void) { #if defined (_OPENMP) do_something(); #endif } /* * ProblemID: 27 * ERROR: Macros with complex values should be enclosed in parentheses * #69: FILE: john_the_ripper/src/aix_ssha_fmt_plug.c:69: * +#define CMP_SIZE BINARY_SIZE - 2 */ #define CMP_SIZE BINARY_SIZE - 2 /* * ProblemID: 28 * ERROR: Macros with multiple statements should be enclosed in a do -while loop * #71: FILE: john_the_ripper/src/AFS_fmt.c:71: * + #define AFS_swap(x, y) \ * + (y) = (x); */ #define AFS_swap(x, y) \ (y) = (x); /* * ProblemID: 29 * ERROR: do not use C99 // comments * #51: FILE: john_the_ripper/src/7z_fmt_plug.c:51: * +#define OMP_SCALE 1 // tuned on core i7 */ #define OMP_SCALE 1 // tuned on core i7 /* * ProblemID: 30 * WARNING: Single statement macros should not use a do {} while (0) loop * #320: FILE: john_the_ripper/src/ripemd_plug.c:320: * + #define sRR(a, b, c, d, f, s, r, k) do { \ * + a = ROTL(SPH_T32(a + f(b, c, d) + r + k), s); \ * + } while (0) */ #define sRR(a, b, c, d, f, s, r, k) do { \ a = ROTL(SPH_T32(a + f(b, c, d) + r + k), s); \ } while (0) /* * ProblemID: 31 * WARNING: Macros with flow control statements should be avoided * #437: FILE: john_the_ripper/src/c3_fmt.c:437: * +#define H0(s) \ * + int i = strlen(s) - 2; \ * + return i > 0 ? H((s), i) & 0xF : 0 * +#define H1(s) \ */ #define H0(s) \ int i = strlen(s) - 2; \ return i > 0 ? H((s), i) & 0xF : 0 /* * ProblemID: 32 * WARNING: plain inline is preferred over __inline * #49: FILE: john_the_ripper/src/blf_plug.c:49: * + #define inline __inline */ #define inline __inline /* * ProblemID: 33 * WARNING: macros should not use a trailing semicolon * #71: FILE: john_the_ripper/src/AFS_fmt.c:71: * + #define AFS_swap(x, y) \ * + (y) = (x); */ #define AFS_swap(x, y) \ (y) = (x); /* * ProblemID: 34 * ERROR: exactly one space required after that #ifdef * #349: FILE: john_the_ripper/src/common_opencl_pbkdf2_plug.c:349: * +#ifdef _DEBUG */ void function(void) { #ifdef _DEBUG struct timeval startc, endc; #endif } /* * ProblemID: 35 * ERROR: return is not a function, parentheses are not required * #323: FILE: john_the_ripper/src/citrix_ns_fmt_plug.c:323: * + return (1); */ int function(void) { return (1); } /* * ProblemID: 36 * ERROR: Bad function definition - void setup_mime() should probably be void * setup_mime(void) * #701: FILE: john_the_ripper/src/base64_convert.c:701: * +static void setup_mime() { * */ void function() { } /* * ProblemID: 37 * ERROR: do not initialise statics to 0 or NULL * #50: FILE: john_the_ripper/src/base64_convert.c:50: * +static int mime_setup=0; */ static int mime_setup=0; /* * ProblemID: 38 * ERROR: inline keyword should sit between storage class and type * #147: FILE: john_the_ripper/src/aix_ssha_fmt_plug.c:147: * + static int inline valid_common(char *ciphertext, * struct fmt_main *self, int b64len, * char *sig, int siglen) */ static int inline valid_common(char *ciphertext, struct fmt_main *self, int b64len, char *sig, int siglen) { do_something(); } /* * ProblemID: 39 * ERROR: do not use assignment in if condition * #117: FILE: john_the_ripper/src/7z_fmt_plug.c:117: * + if ((p = strtokm(ctcopy, "$")) == NULL) */ void function(void) { if ((p = strtokm(ctcopy, "$")) == NULL) goto err; } /* * ProblemID: 40 * WARNING: braces {} are not necessary for single statement blocks * #251: FILE: john_the_ripper/src/7z_fmt_plug.c:251: * + if(AES_set_decrypt_key(derived_key, 256, &akey) < 0) { * + fprintf(stderr, "AES_set_decrypt_key failed in crypt!\n"); * + } */ void function(void) { if(AES_set_decrypt_key(derived_key, 256, &akey) < 0) { fprintf(stderr, "AES_set_decrypt_key failed in crypt!\n"); } } /* * ProblemID: 41 * WARNING: else is not generally useful after a break or return * #474: FILE: john_the_ripper/src/compiler.c:474: * + break; * + } else { */ void function(void) { while (true) { if ((c = c_skip_space()) == '(') { do_something(); break; } else { do_something(); } } } /* * ProblemID: 42 * WARNING: type 'char unsigned' should be specified in * [[un]signed] [short|int|long|long long] order * #130: FILE: john_the_ripper/src/aix_ssha_fmt_plug.c:130: * + char unsigned salt[MAX_SALT_SIZE + 1]; */ static struct custom_salt { int iterations; int type; char unsigned salt[MAX_SALT_SIZE + 1]; } *cur_salt; /* * ProblemID: 43 * WARNING: type 'const char unsigned *' should be specified in * [[un]signed] [short|int|long|long long] order * #58: FILE: john_the_ripper/src/ssh2john.c:58: * + const char unsigned *dc; */ void function(void) { const char unsigned *dc; } /* * ProblemID: 44 * WARNING: static const char * array should probably be static * const char * const * #129: FILE: john_the_ripper/src/opencl_7z_fmt_plug.c:129: * + static const char *warn[] = { */ static const char *warn[] = { "xfer: " , ", init: ", ", crypt: ", ", xfer: " }; /* * ProblemID: 45 * WARNING: char * array declaration might be better as static const * #271: FILE: john_the_ripper/src/common-opencl.c:271: * + char * drivers_info[] = { */ void function(void) { char * drivers_info[] = { "12.8", "13.1", "13.4", }; } /* * ProblemID: 46 * WARNING: line over 80 characters * #57: FILE: john_the_ripper/src/7z_fmt_plug.c:57: * + {"$7z$0$19$0$1122$8$d1f50227759415890000000000000000$1412385885$112$112$5 * e5b8b734adf52a64c541a5a5369023d7cccb78bd910c0092535dfb013a5df84ac692c53 * 11d2e7bbdc580f5b867f7b5dd43830f7b4f37e41c7277e228fb92a6dd854a31646ad117 * 65418225370 6dae0c069d3f4ce46121d52b6f20741a0bb39fc61113ce14d22f9184ada * fd6b5333fb1", "password"}, */ static struct fmt_tests sevenzip_tests[] = { /* CRC checks passes for these hashes */ {"$7z$0$19$0$1122$8$d1f50227759415890000000000000000$1412385885$112$112$5e5b8b734adf52a64c541a5a5369023d7cccb78bd910c0092535dfb013a5df84ac692c5311d2e7bbdc580f5b867f7b5dd43830f7b4f37e41c7277e228fb92a6dd854a31646ad117654182253706dae0c069d3f4ce46121d52b6f20741a0bb39fc61113ce14d22f9184adafd6b5333fb1", "password"}, }; /* * ProblemID: 47 * WARNING: externs should be avoided in .c files * #13: FILE: john_the_ripper/src/7z_fmt_plug.c:13: * + extern struct fmt_main fmt_sevenzip; */ extern struct fmt_main fmt_sevenzip; /* * ProblemID: 48 * WARNING: sizeof result should be sizeof(result) * #292: FILE: john_the_ripper/src/rawSHA1_ng_fmt_plug.c:292: * + strnzcpy(result, kFormatTag, sizeof result); */ void function(void) { strnzcpy(result, kFormatTag, sizeof result); } /* * ProblemID: 49 * WARNING: Avoid line continuations in quoted strings * #272: FILE: john_the_ripper/src/openbsdsoftraid_fmt_plug.c:272: * + {"\ */ static struct fmt_tests tests_openbsdsoftraid[] = { {"\$openbsd-softraid", "password1" }, {NULL} }; /* * ProblemID: 50 * WARNING: Avoid unnecessary line continuations * #246: FILE: john_the_ripper/src/keepass_fmt_plug.c:246: * + fprintf(stderr, "[!] Support for non-inlined data * is currently missing * from the " \ */ void function(void) { fprintf(stderr, "[!] Support for data is currently missing from the " \ " format.\n"); } /* * ProblemID: 51 * WARNING: single byte memset is suspicious. Swapped 2nd/3rd argument? * #323: FILE: john_the_ripper/src/gpg2john.c:323: * +} */ void function(void) { memset(cp, 0, 1); } /* * ProblemID: 52 * WARNING: Too many leading tabs - consider code refactoring * #565: FILE: john_the_ripper/src/DOMINOSEC_fmt_plug.c:565: * + if (ch < 'a' || ch > 'z') */ void function(void) { do { if (apsik < 8) { do { if (ch < '0' || ch > '9') if (ch < 'A' || ch > 'Z') if (ch < 'a' || ch > 'z') if (ch != '+') if (ch == '/') out += '?'; else ; /* shit happens */ else out += '>'; else out += ch-'='; else out += ch-'7'; else out += ch-'0'; ++ascii_cipher; } while (--loop); } } while (++i < 15); } /* * ProblemID: 53 * WARNING: Statements terminations use 1 semicolon * #1722: FILE: john_the_ripper/src/common-opencl.c:1722: * + for (num = autotune_get_next_gws_size(num, step, 1, default_value);; */ void function(void) { for (num = autotune_get_next_gws_size(num, step, 1, default_value);; num = autotune_get_next_gws_size(num, step, 0, default_value)) { size_t kpc = num * opencl_v_width; speed = rounds * raw_speed; } } /* * ProblemID: 54 * WARNING: Unnecessary parentheses * #975: FILE: john_the_ripper/src/common-opencl.c:975: * + if ((build_code != CL_SUCCESS)) { */ void function(void) { if ((build_code != CL_SUCCESS)) { do_something(); do_something(); } } /* * ProblemID: 55 * WARNING: do not add new typedefs * #197: FILE: john_the_ripper/src/charset.c:197: * + typedef struct { */ typedef struct { int index; unsigned int value; } count_sort_t; /* * ProblemID: 56 * WARNING: __func__ should be used instead of gcc specific __FUNCTION__ * #70: FILE: john_the_ripper/src/calc_stat.c:70: * + fprintf(stderr, "%s:%d: malloc failed\n", __FUNCTION__, __LINE__); */ void function(void) { fprintf(stderr, "%s:%d: malloc failed\n", __FUNCTION__, __LINE__); } /* * ProblemID: 57 * WARNING: unchecked sscanf return value * #699: FILE: john_the_ripper/src/c3_fmt.c:699: * + sscanf(c3_salt, "rounds=%d", &rounds); */ void function(void) { sscanf(c3_salt, "rounds=%d", &rounds); } /* * ProblemID: 58 * WARNING: storage class should be at the beginning of the declaration * #39: FILE: john_the_ripper/src/blake2b_plug.c:39: * + JTR_ALIGN( 64 ) static const uint64_t blake2b_IV[8] = */ JTR_ALIGN( 64 ) static const uint64_t blake2b_IV[8] = { 0x510e527fade682d1ULL, 0x9b05688c2b3e6c1fULL, 0x1f83d9abfb41bd6bULL, 0x5be0cd19137e2179ULL }; /* * ProblemID: 59 * WARNING: Use of volatile is usually wrong: see * Documentation/volatile-considered-harmful.txt * #93: FILE: john_the_ripper/src/bench.c:93: * + volatile int bench_running; */ volatile int bench_running; /* * ProblemID: 60 * WARNING: CVS style keyword markers, these will _not_ be updated * #195: FILE: john_the_ripper/src/aix_smd5_fmt_plug.c:195: * + * $Id: md5_crypt.c,v 1.1 2002-05-11 14:42:35 cpbotha Exp $ */ /* * $Id: md5_crypt.c,v 1.1 2002-05-11 14:42:35 cpbotha Exp $ * * ---------------------------------------------------------------------------- * "THE BEER-WARE LICENSE" (Revision 42): * wrote this file. As long as you retain this notice you * can do whatever you want with this stuff. If we meet some day, and you think * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp * ---------------------------------------------------------------------------- * * Origin: Id: crypt.c,v 1.3 1995/05/30 05:42:22 rgrimes Exp * */