diff -urpN JohnTheRipper_orig/src/common-opencl.c JohnTheRipper/src/common-opencl.c --- JohnTheRipper_orig/src/common-opencl.c 2013-01-01 15:31:00.000000000 +0000 +++ JohnTheRipper/src/common-opencl.c 2013-01-01 17:13:47.000000000 +0000 @@ -204,7 +204,7 @@ static void build_kernel(int dev_id, cha #if DEBUG fprintf(stderr, "source size %zu\n", source_size); #endif - source = malloc(source_size); + source = mem_alloc(source_size); HANDLE_CLERROR(clGetProgramInfo(program[dev_id], CL_PROGRAM_BINARIES, sizeof(char *), &source, NULL), "error"); diff -urpN JohnTheRipper_orig/src/ike-crack.h JohnTheRipper/src/ike-crack.h --- JohnTheRipper_orig/src/ike-crack.h 2013-01-01 15:31:00.000000000 +0000 +++ JohnTheRipper/src/ike-crack.h 2013-01-01 17:11:21.000000000 +0000 @@ -147,7 +147,7 @@ static unsigned char *hex2data(const cha } len = strlen(string) / 2; - data = malloc(len); + data = mem_alloc(len); cp = data; for (i = 0; i < len; i++) *cp++ = hstr_i(&string[i * 2]); diff -urpN JohnTheRipper_orig/src/keepass2john.c JohnTheRipper/src/keepass2john.c --- JohnTheRipper_orig/src/keepass2john.c 2013-01-01 15:31:00.000000000 +0000 +++ JohnTheRipper/src/keepass2john.c 2013-01-01 17:10:39.000000000 +0000 @@ -231,7 +231,7 @@ static void process_database(char* encry if (uSize > 0) { - pbData = (unsigned char*)malloc(uSize); + pbData = (unsigned char*)mem_alloc(uSize); if (fread(pbData, uSize, 1, fp) != 1) { fprintf(stderr, "error reading pbData\n"); return; diff -urpN JohnTheRipper_orig/src/keyring2john.c JohnTheRipper/src/keyring2john.c --- JohnTheRipper_orig/src/keyring2john.c 2013-01-01 15:31:00.000000000 +0000 +++ JohnTheRipper/src/keyring2john.c 2013-01-01 17:10:15.000000000 +0000 @@ -180,7 +180,7 @@ static void process_file(const char *fna if (crypto_size % 16 != 0) goto bail; - to_decrypt = (unsigned char *) malloc(crypto_size); + to_decrypt = (unsigned char *) mem_alloc(crypto_size); count = fread(to_decrypt, crypto_size, 1, fp); assert(count == 1); printf("%s:$keyring$", fname); diff -urpN JohnTheRipper_orig/src/KRB5_std_plug.c JohnTheRipper/src/KRB5_std_plug.c --- JohnTheRipper_orig/src/KRB5_std_plug.c 2013-01-01 15:31:00.000000000 +0000 +++ JohnTheRipper/src/KRB5_std_plug.c 2013-01-01 15:44:23.000000000 +0000 @@ -54,7 +54,7 @@ static inline void rr13(unsigned char *b if(len == 0) return; - tmp = (unsigned char *) malloc(bytes); + tmp = (unsigned char *) mem_alloc(bytes); memcpy(tmp, buf, bytes); if(lbit) { // pad final byte with inital bits @@ -108,8 +108,8 @@ static inline void add1(unsigned char *a static inline void _krb5_n_fold(const void *str, int len, void *key, int size) { int maxlen = 2 * max(size, len), l = 0; - unsigned char *tmp = (unsigned char *) malloc(maxlen); - unsigned char *buf = (unsigned char *) malloc(len); + unsigned char *tmp = (unsigned char *) mem_alloc(maxlen); + unsigned char *buf = (unsigned char *) mem_alloc(len); memcpy(buf, str, len); memset(key, 0, size); @@ -183,11 +183,8 @@ static inline void derive_key(const void if(DES3_BLOCK_SIZE * 8 < DES3_KEY_BITS || len != DES3_BLOCK_SIZE) { nblocks = (DES3_KEY_BITS + DES3_BLOCK_SIZE * 8 - 1) / (DES3_BLOCK_SIZE * 8); - k = (unsigned char *) malloc(nblocks * DES3_BLOCK_SIZE); - if(k == NULL) { - printf("malloc: out of memory\n"); - exit(1); - } + k = (unsigned char *) mem_alloc(nblocks * DES3_BLOCK_SIZE); + _krb5_n_fold(constant, len, k, DES3_BLOCK_SIZE); for(i = 0; i < nblocks; i++) { if(i > 0) @@ -216,12 +213,8 @@ static inline void string_to_key_derived unsigned char *tmp; - tmp = (unsigned char *) malloc(DES3_KEY_BITS_BYTES); - if(tmp == NULL) { - printf("malloc: out of memory\n"); - // FIXME make it real return value if sometime this is needed - exit(1); - } + tmp = (unsigned char *) mem_alloc(DES3_KEY_BITS_BYTES); + _krb5_n_fold(passwd, len, tmp, DES3_KEY_BITS_BYTES); DES3_postproc(tmp, DES3_KEY_BITS_BYTES, krb5key); @@ -260,10 +253,7 @@ void str2key(char *user, char *realm, ch int offset = 0; char *text; - text = (char*) malloc(strlen(user) + strlen(realm) + strlen(passwd)); - if (text == NULL) { - return; - } + text = (char*) mem_alloc(strlen(user) + strlen(realm) + strlen(passwd)); memset(krb5key->key, 0x00, DES3_KEY_SIZE); memset(krb5key->schedule, 0x00, DES3_KEY_SCHED_SIZE); diff -urpN JohnTheRipper_orig/src/opencl_mscash2_fmt.c JohnTheRipper/src/opencl_mscash2_fmt.c --- JohnTheRipper_orig/src/opencl_mscash2_fmt.c 2013-01-01 15:31:00.000000000 +0000 +++ JohnTheRipper/src/opencl_mscash2_fmt.c 2013-01-01 16:46:51.000000000 +0000 @@ -199,9 +199,9 @@ static void init(struct fmt_main *self) ///Alocate memory key_host = calloc(self->params.max_keys_per_crypt, sizeof(*key_host)); - dcc_hash_host=(cl_uint*)malloc(4*sizeof(cl_uint)*MAX_KEYS_PER_CRYPT); + dcc_hash_host=(cl_uint*)mem_alloc_tiny(4*sizeof(cl_uint)*MAX_KEYS_PER_CRYPT,MEM_ALIGN_WORD); - dcc2_hash_host=(cl_uint*)malloc(4*sizeof(cl_uint)*MAX_KEYS_PER_CRYPT); + dcc2_hash_host=(cl_uint*)mem_alloc_tiny(4*sizeof(cl_uint)*MAX_KEYS_PER_CRYPT,MEM_ALIGN_WORD); memset(dcc_hash_host,0,4*sizeof(cl_uint)*MAX_KEYS_PER_CRYPT); diff -urpN JohnTheRipper_orig/src/opencl_mysqlsha1_fmt.c JohnTheRipper/src/opencl_mysqlsha1_fmt.c --- JohnTheRipper_orig/src/opencl_mysqlsha1_fmt.c 2013-01-01 15:31:00.000000000 +0000 +++ JohnTheRipper/src/opencl_mysqlsha1_fmt.c 2013-01-01 16:45:11.000000000 +0000 @@ -136,7 +136,7 @@ static void find_best_kpc(void){ clGetEventProfilingInfo(myEvent, CL_PROFILING_COMMAND_SUBMIT, sizeof(cl_ulong), &startTime, NULL); clGetEventProfilingInfo(myEvent, CL_PROFILING_COMMAND_END , sizeof(cl_ulong), &endTime , NULL); tmpTime = endTime-startTime; - tmpbuffer = malloc(sizeof(cl_uint) * num); + tmpbuffer = mem_alloc(sizeof(cl_uint) * num); clEnqueueReadBuffer(queue_prof, buf_msha_out, CL_TRUE, 0, sizeof(cl_uint) * num, tmpbuffer, 0, NULL, &myEvent); clGetEventProfilingInfo(myEvent, CL_PROFILING_COMMAND_SUBMIT, sizeof(cl_ulong), &startTime, NULL); clGetEventProfilingInfo(myEvent, CL_PROFILING_COMMAND_END , sizeof(cl_ulong), &endTime , NULL); diff -urpN JohnTheRipper_orig/src/opencl_nsldaps_fmt.c JohnTheRipper/src/opencl_nsldaps_fmt.c --- JohnTheRipper_orig/src/opencl_nsldaps_fmt.c 2013-01-01 15:31:00.000000000 +0000 +++ JohnTheRipper/src/opencl_nsldaps_fmt.c 2013-01-01 16:44:46.000000000 +0000 @@ -210,7 +210,7 @@ static void find_best_gws(int do_benchma clGetEventProfilingInfo(myEvent, CL_PROFILING_COMMAND_SUBMIT, sizeof(cl_ulong), &startTime, NULL); clGetEventProfilingInfo(myEvent, CL_PROFILING_COMMAND_END , sizeof(cl_ulong), &endTime , NULL); tmpTime = endTime-startTime; - tmpbuffer = malloc(sizeof(cl_uint) * gws); + tmpbuffer = mem_alloc(sizeof(cl_uint) * gws); clEnqueueReadBuffer(queue_prof, buffer_out, CL_TRUE, 0, sizeof(cl_uint) * gws, tmpbuffer, 0, NULL, &myEvent); clGetEventProfilingInfo(myEvent, CL_PROFILING_COMMAND_SUBMIT, sizeof(cl_ulong), &startTime, NULL); clGetEventProfilingInfo(myEvent, CL_PROFILING_COMMAND_END , sizeof(cl_ulong), &endTime , NULL); diff -urpN JohnTheRipper_orig/src/opencl_rawsha1_fmt.c JohnTheRipper/src/opencl_rawsha1_fmt.c --- JohnTheRipper_orig/src/opencl_rawsha1_fmt.c 2013-01-01 15:31:00.000000000 +0000 +++ JohnTheRipper/src/opencl_rawsha1_fmt.c 2013-01-01 16:40:26.000000000 +0000 @@ -152,7 +152,7 @@ static void find_best_kpc(void){ clGetEventProfilingInfo(myEvent, CL_PROFILING_COMMAND_SUBMIT, sizeof(cl_ulong), &startTime, NULL); clGetEventProfilingInfo(myEvent, CL_PROFILING_COMMAND_END , sizeof(cl_ulong), &endTime , NULL); tmpTime = endTime-startTime; - tmpbuffer = malloc(sizeof(cl_uint) * num); + tmpbuffer = mem_alloc(sizeof(cl_uint) * num); clEnqueueReadBuffer(queue_prof, buffer_out, CL_TRUE, 0, sizeof(cl_uint) * num, tmpbuffer, 0, NULL, &myEvent); clGetEventProfilingInfo(myEvent, CL_PROFILING_COMMAND_SUBMIT, sizeof(cl_ulong), &startTime, NULL); clGetEventProfilingInfo(myEvent, CL_PROFILING_COMMAND_END , sizeof(cl_ulong), &endTime , NULL); diff -urpN JohnTheRipper_orig/src/options.c JohnTheRipper/src/options.c --- JohnTheRipper_orig/src/options.c 2013-01-01 15:31:00.000000000 +0000 +++ JohnTheRipper/src/options.c 2013-01-01 17:04:44.000000000 +0000 @@ -239,7 +239,7 @@ static void print_usage(char *name) while ((format = format->next)) i++; - formats_list = malloc(sizeof(char*) * i); + formats_list = mem_alloc(sizeof(char*) * i); i = 0; format = fmt_list; diff -urpN JohnTheRipper_orig/src/pdfparser.c JohnTheRipper/src/pdfparser.c --- JohnTheRipper_orig/src/pdfparser.c 2013-01-01 15:31:00.000000000 +0000 +++ JohnTheRipper/src/pdfparser.c 2013-01-01 17:03:48.000000000 +0000 @@ -131,7 +131,7 @@ static char *parseName(FILE * file) } ungetc(ch, file); buff[i++] = '\0'; - ret = malloc(sizeof(char) * i); + ret = mem_alloc(sizeof(char) * i); memcpy(ret, buff, i); return ret; } @@ -207,8 +207,8 @@ static p_str *parseHexString(const uint8 unsigned int i, j; p_str *ret; - ret = malloc(sizeof(p_str)); - ret->content = malloc(sizeof(uint8_t) * (len / 2)); + ret = mem_alloc(sizeof(p_str)); + ret->content = mem_alloc(sizeof(uint8_t) * (len / 2)); ret->len = (len / 2); for (i = 0, j = 0; i < len; i += 2) { @@ -285,8 +285,8 @@ static p_str *objStringToByte(const uint tmp[l] = b; } - ret = malloc(sizeof(p_str)); - ret->content = malloc(sizeof(uint8_t) * (l)); + ret = mem_alloc(sizeof(p_str)); + ret->content = mem_alloc(sizeof(uint8_t) * (l)); ret->len = l - 1; memcpy(ret->content, tmp, l); diff -urpN JohnTheRipper_orig/src/pfx_fmt.c JohnTheRipper/src/pfx_fmt.c --- JohnTheRipper_orig/src/pfx_fmt.c 2013-01-01 15:31:00.000000000 +0000 +++ JohnTheRipper/src/pfx_fmt.c 2013-01-01 16:28:18.000000000 +0000 @@ -142,7 +142,7 @@ static void *get_salt(char *ciphertext) ctcopy += 6; /* skip over "$pfx$*" */ p = strtok(ctcopy, "*"); cs.len = atoi(p); - decoded_data = (char *) malloc(cs.len + 1); + decoded_data = (char *) mem_alloc(cs.len + 1); p = strtok(NULL, "*"); for (i = 0; i < cs.len; i++) decoded_data[i] = atoi16[ARCH_INDEX(p[i * 2])] * 16 + diff -urpN JohnTheRipper_orig/src/putty2john.c JohnTheRipper/src/putty2john.c --- JohnTheRipper_orig/src/putty2john.c 2013-01-01 15:31:00.000000000 +0000 +++ JohnTheRipper/src/putty2john.c 2013-01-01 17:01:19.000000000 +0000 @@ -147,7 +147,7 @@ static char *read_body(FILE * fp) int c; size = 128; - text = (char*)malloc(size); + text = (char*)mem_alloc(size); len = 0; text[len] = '\0'; @@ -180,7 +180,7 @@ static unsigned char *read_blob(FILE * f int i, j, k; /* We expect at most 64 base64 characters, ie 48 real bytes, per line. */ - blob = (unsigned char*)malloc(48 * nlines); + blob = (unsigned char*)mem_alloc(48 * nlines); len = 0; for (i = 0; i < nlines; i++) { line = read_body(fp); @@ -585,8 +585,8 @@ int main(int argc, char **argv) return 1; } // printf("len: %i/%i\n", public_blob_len, private_blob_len); - private_blobXX=(unsigned char*)malloc(private_blob_len); - public_blobXX=(unsigned char*)malloc(public_blob_len); + private_blobXX=(unsigned char*)mem_alloc(private_blob_len); + public_blobXX=(unsigned char*)mem_alloc(public_blob_len); if (type == SSH_KEYTYPE_SSH1) { fprintf(stderr, "SSH1 key type not supported!\n"); diff -urpN JohnTheRipper_orig/src/putty_fmt_plug.c JohnTheRipper/src/putty_fmt_plug.c --- JohnTheRipper_orig/src/putty_fmt_plug.c 2013-01-01 15:31:00.000000000 +0000 +++ JohnTheRipper/src/putty_fmt_plug.c 2013-01-01 15:45:56.000000000 +0000 @@ -271,7 +271,7 @@ static int LAME_ssh2_load_userkey(char * 4 + commlen + 4 + cur_salt->public_blob_len + 4 + cur_salt->private_blob_len); - macdata = (unsigned char*)malloc(maclen); + macdata = (unsigned char*)mem_alloc(maclen); p = macdata; #define DO_STR(s,len) PUT_32BIT(p,(len));memcpy(p+4,(s),(len));p+=4+(len) DO_STR(cur_salt->alg, namelen); diff -urpN JohnTheRipper_orig/src/racf2john.c JohnTheRipper/src/racf2john.c --- JohnTheRipper_orig/src/racf2john.c 2013-01-01 15:31:00.000000000 +0000 +++ JohnTheRipper/src/racf2john.c 2013-01-01 16:59:41.000000000 +0000 @@ -75,7 +75,7 @@ static void process_file(const char *fil } size = sb.st_size; - buffer = (unsigned char *)malloc(size); + buffer = (unsigned char *)mem_alloc(size); count = fread(buffer, size, 1, fp); assert(count == 1); diff -urpN JohnTheRipper_orig/src/rules.c JohnTheRipper/src/rules.c --- JohnTheRipper_orig/src/rules.c 2013-01-01 15:31:00.000000000 +0000 +++ JohnTheRipper/src/rules.c 2013-01-01 16:59:04.000000000 +0000 @@ -220,7 +220,7 @@ static void rules_init_class(char name, static char *userclass_expand(const char *src) { unsigned const char *src2 = (unsigned char*)src; - char *dst_tmp = malloc(0x200); + char *dst_tmp = mem_alloc(0x200); char *dst = dst_tmp, *dstend = &dst_tmp[0x100]; int j, br = 0; diff -urpN JohnTheRipper_orig/src/SIPdump.h JohnTheRipper/src/SIPdump.h --- JohnTheRipper_orig/src/SIPdump.h 2013-01-01 15:31:00.000000000 +0000 +++ JohnTheRipper/src/SIPdump.h 2013-01-01 16:55:28.000000000 +0000 @@ -107,12 +107,7 @@ void *Malloc(size_t size) { void *buffer; - buffer = malloc(size); - - if (buffer == NULL) { - fprintf(stderr, "malloc() failed: %s\n", strerror(errno)); - exit(EXIT_FAILURE); - } + buffer = mem_alloc(size); memset(buffer, 0, size); diff -urpN JohnTheRipper_orig/src/ssh_fmt.c JohnTheRipper/src/ssh_fmt.c --- JohnTheRipper_orig/src/ssh_fmt.c 2013-01-01 15:31:00.000000000 +0000 +++ JohnTheRipper/src/ssh_fmt.c 2013-01-01 16:25:58.000000000 +0000 @@ -252,7 +252,7 @@ static void *get_salt(char *ciphertext) } filelength = atoi(strtok(NULL, "*")); encoded_data += 6; /* skip over "$ssh2$ marker */ - decoded_data = (char *) malloc(filelength + 1); + decoded_data = (char *) mem_alloc(filelength + 1); for (i = 0; i < filelength; i++) decoded_data[i] = atoi16[ARCH_INDEX(encoded_data[i * 2])] * 16 +