- Timestamp:
- Jun 29, 2014, 7:30:04 AM (10 years ago)
- Location:
- trunk
- Files:
-
- 21 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/configure.ac
r447 r454 12 12 dnl start 13 13 dnl 14 AM_INIT_AUTOMAKE(samhain, 3.1. 1)14 AM_INIT_AUTOMAKE(samhain, 3.1.2) 15 15 AC_DEFINE([SAMHAIN], 1, [Application is samhain]) 16 16 AC_CANONICAL_HOST -
trunk/docs/Changelog
r449 r454 1 3.1.2: 2 * Fixed incorrect memset in sh_checksum.c (sha256) 3 * Circumvent a gcc compiler bug with inline asm (gcc 4.8) 4 * Allow multiple exclusions for SUID check 5 * Use calloc instead of malloc 6 1 7 3.1.1 (01-0-2014): 2 8 * Disable inline asm on Cygwin (issue reported by Erik) -
trunk/src/bignum.c
r435 r454 64 64 #define ulong unsigned long 65 65 66 /*67 extern void *malloc(size_t size);68 extern void free();69 */70 71 66 char *last_string = NULL; 72 67 char *big_end_string = NULL; … … 232 227 dgs_alloc += alloclen; 233 228 #endif 234 digit_ptr = (DIGIT *) malloc(alloclen *sizeof(DIGIT));229 digit_ptr = calloc(alloclen, sizeof(DIGIT)); 235 230 if (digit_ptr == NULL) 236 231 { … … 625 620 big_set_long((long)1, &big_one); 626 621 length_last_string = 10; 627 if ((last_string = malloc(length_last_string)) == NULL)622 if ((last_string = calloc(1,length_last_string)) == NULL) 628 623 { 629 624 big_errno = BIG_MEMERR; … … 955 950 if (last_string != NULL) 956 951 free(last_string); 957 if ((last_string = malloc(str_length)) == NULL)952 if ((last_string = calloc(1,str_length)) == NULL) 958 953 { 959 954 big_errno = BIG_MEMERR; -
trunk/src/samhain.c
r433 r454 150 150 int sh_g_thread() 151 151 { 152 struct gt * ptr = malloc(sizeof(struct gt));152 struct gt * ptr = calloc(1,sizeof(struct gt)); 153 153 if (!ptr) 154 154 return -1; … … 640 640 /* The struct to hold privileged information. 641 641 */ 642 skey = (sh_key_t *) malloc (sizeof(sh_key_t));642 skey = calloc(1,sizeof(sh_key_t)); 643 643 if (skey != NULL) 644 644 { … … 862 862 SH_MUTEX_LOCK(mutex_readdir); 863 863 864 pidlist = malloc(sizeof(pid_t) * 65535);864 pidlist = calloc(1, sizeof(pid_t) * 65535); 865 865 if (!pidlist) 866 866 goto unlock_and_out; … … 1376 1376 if (tzlen < 1024) 1377 1377 { 1378 sh.timezone = malloc (tzlen + 1);1378 sh.timezone = calloc(1, tzlen + 1); 1379 1379 if (sh.timezone != NULL) 1380 1380 (void) sl_strlcpy (sh.timezone, tzptr, tzlen + 1); -
trunk/src/sh_database.c
r427 r454 1484 1484 { 1485 1485 j = strlen(attr_tab[i].attr_o); 1486 attr_tab[i].attr = malloc (j+1); /* only once */1486 attr_tab[i].attr = calloc(1, j+1); /* only once */ 1487 1487 if (NULL == attr_tab[i].attr) 1488 1488 return; -
trunk/src/sh_entropy.c
r345 r454 548 548 { 549 549 len = sl_strlen(sh.timezone) + 4; 550 envp[0] = malloc (len); /* free() ok */550 envp[0] = calloc(1, len); /* free() ok */ 551 551 if (envp[0] != NULL) 552 552 sl_snprintf (envp[0], len, "TZ=%s", sh.timezone); -
trunk/src/sh_filetype.c
r310 r454 472 472 473 473 #ifdef SH_FILE_MAIN 474 sh_ftype_arr = malloc((nn+1) *sizeof(struct sh_ftype_rec *));474 sh_ftype_arr = calloc((nn+1), sizeof(struct sh_ftype_rec *)); 475 475 #else 476 476 sh_ftype_arr = SH_ALLOC((nn+1) * sizeof(struct sh_ftype_rec *)); … … 480 480 { 481 481 #ifdef SH_FILE_MAIN 482 sh_ftype_arr[i] = malloc(sizeof(struct sh_ftype_rec));482 sh_ftype_arr[i] = calloc(1, sizeof(struct sh_ftype_rec)); 483 483 #else 484 484 sh_ftype_arr[i] = SH_ALLOC(sizeof(struct sh_ftype_rec)); -
trunk/src/sh_gpg.c
r391 r454 422 422 { 423 423 len = sl_strlen(sh.effective.home) + 6; 424 envp[0] = malloc (len); /* free() ok */424 envp[0] = calloc(1, len); /* free() ok */ 425 425 if (envp[0] != NULL) 426 426 sl_snprintf (envp[0], len, _("HOME=%s"), sh.effective.home); -
trunk/src/sh_html.c
r415 r454 317 317 else 318 318 { 319 entry_orig = malloc(line_size + 1); /* free() ok */319 entry_orig = calloc(1, line_size + 1); /* free() ok */ 320 320 if (entry_orig) { entry_orig[0] = '\0'; add_size = line_size; } 321 321 } -
trunk/src/sh_inotify.c
r405 r454 72 72 if ((ptr = pthread_getspecific(inotify_key)) == NULL) 73 73 { 74 ptr = malloc(sizeof(int));74 ptr = calloc(1,sizeof(int)); 75 75 if (ptr) 76 76 { -
trunk/src/sh_mem.c
r292 r454 142 142 while (this != NULL) 143 143 { 144 memlist_t * merr = (memlist_t *) malloc (sizeof(memlist_t));144 memlist_t * merr = calloc(1,sizeof(memlist_t)); 145 145 146 146 memcpy(merr, this, sizeof(memlist_t)); … … 191 191 if ( this->address == NULL ) 192 192 { 193 merr = (memlist_t *) malloc (sizeof(memlist_t));193 merr = calloc (1,sizeof(memlist_t)); 194 194 195 195 memcpy(merr, this, sizeof(memlist_t)); … … 204 204 if ( this->address[this->size] != CHECKBYTE ) 205 205 { 206 merr = (memlist_t *) malloc (sizeof(memlist_t));206 merr = calloc(1, sizeof(memlist_t)); 207 207 208 208 memcpy(merr, this, sizeof(memlist_t)); … … 215 215 if ( this->real_address[SH_MEMMULT-1] != CHECKBYTE ) 216 216 { 217 merr = (memlist_t *) malloc (sizeof(memlist_t));217 merr = calloc(1, sizeof(memlist_t)); 218 218 219 219 memcpy(merr, this, sizeof(memlist_t)); … … 262 262 SH_MUTEX_RECURSIVE_LOCK(mutex_mem); 263 263 264 the_realAddress = malloc(size + 2 * SH_MEMMULT);264 the_realAddress = calloc(1,size + 2 * SH_MEMMULT); 265 265 266 266 if ( the_realAddress == NULL ) … … 290 290 Mem_Max = ( (Mem_Current > Mem_Max) ? Mem_Current : Mem_Max); 291 291 292 this = (memlist_t *) malloc (sizeof(memlist_t));292 this = calloc(1,sizeof(memlist_t)); 293 293 294 294 if ( this == NULL) … … 370 370 if ( this->address[this->size] != CHECKBYTE ) 371 371 { 372 merr = (memlist_t *) malloc (sizeof(memlist_t));372 merr = calloc(1, sizeof(memlist_t)); 373 373 374 374 memcpy(merr, this, sizeof(memlist_t)); … … 381 381 if ( this->real_address[SH_MEMMULT-1] != CHECKBYTE ) 382 382 { 383 merr = (memlist_t *) malloc (sizeof(memlist_t));383 merr = calloc(1,sizeof(memlist_t)); 384 384 385 385 memcpy(merr, this, sizeof(memlist_t)); … … 454 454 SL_ENTER(_("sh_mem_malloc")); 455 455 456 theAddress = malloc(size);456 theAddress = calloc(1,size); 457 457 458 458 if ( theAddress != NULL ) -
trunk/src/sh_schedule.c
r290 r454 335 335 len = strlen(ssched)+1; 336 336 #ifdef TESTONLY 337 copy = malloc(len); /* testonly code */337 copy = calloc(1,len); /* testonly code */ 338 338 #else 339 339 copy = SH_ALLOC(len); -
trunk/src/sh_srp.c
r225 r454 96 96 if (get_str_internal == NULL) 97 97 { 98 get_str_internal = malloc(512); /* only once */98 get_str_internal = calloc(1,512); /* only once */ 99 99 if (get_str_internal) 100 100 { -
trunk/src/sh_static.c
r428 r454 469 469 struct group group; 470 470 471 char * buff = malloc(GRP_BUFFER_SIZE_MALLOC);471 char * buff = calloc(1,GRP_BUFFER_SIZE_MALLOC); 472 472 473 473 rv = -1; 474 474 475 475 /* We alloc space for 8 gids at a time. */ 476 if (((group_list = (gid_t *) malloc(8*sizeof(gid_t *))) != NULL)476 if (((group_list = calloc(8,sizeof(gid_t *))) != NULL) 477 477 && ((grf = fopen(_PATH_GROUP, "r")) != NULL) 478 478 ) { … … 1177 1177 struct resolv_question q; 1178 1178 int retries = 0; 1179 unsigned char * packet = malloc(PACKETSZ);1180 char *dns, *lookup = malloc(MAXDNAME);1179 unsigned char * packet = calloc(1,PACKETSZ); 1180 char *dns, *lookup = calloc(1,MAXDNAME); 1181 1181 int variant = 0; 1182 1182 struct sockaddr_in sa; -
trunk/src/sh_unix.c
r436 r454 1475 1475 1476 1476 /* printf("-> %2d: slots allocated\n", envlen); */ 1477 env1 = malloc (sizeof(char *) * envlen); /* only once */1477 env1 = calloc(1,sizeof(char *) * envlen); /* only once */ 1478 1478 if (env1 == NULL) 1479 1479 { … … 1486 1486 while (env0 != NULL && env0[envlen] != NULL) { 1487 1487 len = strlen(env0[envlen]) + 1; 1488 env1[envlen] = malloc (len); /* only once */1488 env1[envlen] = calloc(1,len); /* only once */ 1489 1489 if (env1[envlen] == NULL) 1490 1490 { … … 1910 1910 { 1911 1911 len = strlen(str) + 1; 1912 chroot_dir = malloc(strlen(str) + 1); /* only once */1912 chroot_dir = calloc(1,strlen(str) + 1); /* only once */ 1913 1913 if (!chroot_dir) 1914 1914 { … … 4349 4349 sh_error_handle (level, FIL__, __LINE__, stat_return, 4350 4350 MSG_FI_STAT, 4351 _("lstat "),4351 _("lstat (link target)"), 4352 4352 sh_error_message (stat_return,errbuf, sizeof(errbuf)), 4353 4353 (long) euid, … … 5568 5568 ptr = pthread_getspecific(gSigtrapVariables_key); 5569 5569 if (ptr == NULL) { 5570 ptr = malloc(sizeof(struct sh_sigtrap_variables));5570 ptr = calloc(1,sizeof(struct sh_sigtrap_variables)); 5571 5571 if (ptr == NULL) { 5572 5572 return NULL; -
trunk/src/sh_utils.c
r444 r454 1255 1255 } 1256 1256 1257 if (NULL == (new = malloc(strlen(new_in) + 1)))1257 if (NULL == (new = calloc(1,strlen(new_in) + 1))) 1258 1258 goto bail_mem; 1259 1259 sl_strncpy(new, new_in, strlen(new_in) + 1); … … 1282 1282 len = strlen(path) + 1 + 4; 1283 1283 /*@-usedef@*/ 1284 if (NULL == (outpath = malloc(len)))1284 if (NULL == (outpath = calloc(1,len))) 1285 1285 goto bail_mem; 1286 1286 /*@-usedef@*/ … … 1310 1310 1311 1311 1312 image = malloc (4096);1312 image = calloc(1,4096); 1313 1313 if (!image) 1314 1314 goto bail_mem; -
trunk/src/slib.c
r412 r454 1493 1493 char * buffer; 1494 1494 struct passwd * tempres; 1495 buffer = malloc(SH_PWBUF_SIZE);1495 buffer = calloc(1,SH_PWBUF_SIZE); 1496 1496 SL_REQUIRE (buffer != NULL, _("buffer != NULL")); 1497 1497 sh_getpwnam_r(user, &pwd, buffer, SH_PWBUF_SIZE, &tempres); … … 1542 1542 char * buffer; 1543 1543 struct passwd * tempres; 1544 buffer = malloc(SH_PWBUF_SIZE);1544 buffer = calloc(1,SH_PWBUF_SIZE); 1545 1545 SL_REQUIRE (buffer != NULL, _("buffer != NULL")); 1546 1546 sh_getpwnam_r(user, &pwd, buffer, SH_PWBUF_SIZE, &tempres); … … 1756 1756 } 1757 1757 1758 if ( (ofiles[fd] = (SL_OFILE *) malloc(sizeof(SL_OFILE))) == NULL)1758 if ( (ofiles[fd] = calloc(1,sizeof(SL_OFILE))) == NULL) 1759 1759 { 1760 1760 SL_IRETURN(SL_EMEM, _("sl_make_ticket")); … … 1763 1763 len = sl_strlen(filename)+1; 1764 1764 1765 if ( (ofiles[fd]->path = (char *) malloc(len) ) == NULL)1765 if ( (ofiles[fd]->path = calloc(1,len) ) == NULL) 1766 1766 { 1767 1767 free (ofiles[fd]); … … 2032 2032 } 2033 2033 2034 if ( (ofiles[fd] = (SL_OFILE *) malloc(sizeof(SL_OFILE))) == NULL)2034 if ( (ofiles[fd] = calloc(1,sizeof(SL_OFILE))) == NULL) 2035 2035 { 2036 2036 sl_close_fd(FIL__, __LINE__, fd); … … 2040 2040 len = sl_strlen(filename)+1; 2041 2041 2042 if ( (ofiles[fd]->path = (char *) malloc(len) ) == NULL)2042 if ( (ofiles[fd]->path = calloc(1,len) ) == NULL) 2043 2043 { 2044 2044 free (ofiles[fd]); -
trunk/src/sstrip.c
r286 r454 178 178 179 179 size = ehdr->e_phnum * sizeof **phdrs; 180 if (!(*phdrs = malloc(size)))180 if (!(*phdrs = calloc(1,size))) 181 181 return err("Out of memory!"); 182 182 … … 196 196 197 197 size = ehdr->e_phnum * sizeof **phdrs; 198 if (!(*phdrs = malloc(size)))198 if (!(*phdrs = calloc(1,size))) 199 199 return err("Out of memory!"); 200 200 -
trunk/src/t-test1.c
r229 r454 27 27 * allocated bins per thread. 28 28 */ 29 /* 30 t-test[12] <n-total> <n-parallel> <n-allocs> <size-max> <bins> 31 32 n-total = total number of threads executed (default 10) 33 n-parallel = number of threads running in parallel (2) 34 n-allocs = number of malloc()'s / free()'s per thread (10000) 35 size-max = max. size requested with malloc() in bytes (10000) 36 bins = number of bins to maintain 37 */ 38 29 39 #if defined(HAVE_CONFIG_H) 30 40 #include "config.h" … … 52 62 53 63 #ifdef USE_SYSTEM_MALLOC 54 #define memalign(a,b) malloc(b) 64 extern void *memalign(size_t boundary, size_t size); 65 /* #define memalign(a,b) malloc(b) */ 55 66 #else 56 67 extern void *memalign(size_t boundary, size_t size); … … 203 214 /* Allocate a bin with malloc(), realloc() or memalign(). r must be a 204 215 random number >= 1024. */ 216 int n_malloc=0, n_memalign=0, n_realloc=0, n_calloc=0; 205 217 206 218 static void … … 219 231 m->ptr = (unsigned char *)memalign(sizeof(int) << r, size); 220 232 /* fprintf(stderr, "FIXME memalign %p\n", m->ptr); */ 233 ++n_memalign; 221 234 } else if(r < 20) { /* calloc */ 222 235 if(m->size > 0) free(m->ptr); … … 232 245 } 233 246 #endif 247 ++n_calloc; 234 248 /* fprintf(stderr, "FIXME calloc %p\n", m->ptr); */ 235 249 } else if(r < 100 && m->size < REALLOC_MAX) { /* realloc */ … … 237 251 m->ptr = realloc(m->ptr, size); 238 252 /* fprintf(stderr, "FIXME realloc %p\n", m->ptr); */ 253 ++n_realloc; 239 254 } else { /* plain malloc */ 240 255 if(m->size > 0) free(m->ptr); 241 256 m->ptr = (unsigned char *)malloc(size); 242 257 /* fprintf(stderr, "FIXME malloc %p\n", m->ptr); */ 258 ++n_malloc; 243 259 } 244 260 if(!m->ptr) { … … 540 556 if (verbose) 541 557 if(n_total%N_TOTAL_PRINT == 0) 542 printf("n_total = %d\n", n_total); 558 printf("n_total = %8d - malloc %12d / memalign %12d / realloc %12d / calloc %12d\n", 559 n_total, 560 n_malloc, n_memalign, n_realloc, n_calloc); 543 561 544 562 } … … 578 596 printf("ptmalloc_init\n"); 579 597 #endif 598 599 if((argc > 1) && (0 == strcmp(argv[1], "-h") || 0 == strcmp(argv[1], "--help"))) 600 { 601 printf("%s <n-total> <n-parallel> <n-allocs> <size-max> <bins>\n\n", argv[0]); 602 printf(" n-total = total number of threads executed (default 10)\n"); 603 printf(" n-parallel = number of threads running in parallel (2)\n"); 604 printf(" n-allocs = number of malloc()'s / free()'s per thread (10000)\n"); 605 printf(" size-max = max. size requested with malloc() in bytes (10000)\n"); 606 printf(" bins = number of bins to maintain\n"); 607 return 0; 608 } 580 609 581 610 if(argc > 1) n_total_max = atoi(argv[1]); -
trunk/src/trustfile.c
r430 r454 436 436 437 437 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETGRGID_R) 438 buffer = malloc(SH_GRBUF_SIZE);438 buffer = calloc(1,SH_GRBUF_SIZE); 439 439 status = sh_getgrgid_r(grp, &gr, buffer, SH_GRBUF_SIZE, &g); 440 440 #else … … 455 455 */ 456 456 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETGRGID_R) 457 pbuffer = malloc(SH_PWBUF_SIZE);457 pbuffer = calloc(1,SH_PWBUF_SIZE); 458 458 #endif 459 459 … … 549 549 550 550 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETGRGID_R) 551 buffer = malloc(SH_GRBUF_SIZE);551 buffer = calloc(1,SH_GRBUF_SIZE); 552 552 status = sh_getgrgid_r(grp, &gr, buffer, SH_GRBUF_SIZE, &g); 553 553 #else … … 580 580 */ 581 581 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_GETPWNAM_R) 582 pbuffer = malloc(SH_PWBUF_SIZE);582 pbuffer = calloc(1,SH_PWBUF_SIZE); 583 583 #endif 584 584 … … 747 747 SL_IRETURN(SL_EBADFILE, _("sl_trustfile")); 748 748 749 fexp = malloc(MAXFILENAME );749 fexp = calloc(1, MAXFILENAME ); 750 750 if (!fexp) 751 751 SL_IRETURN(SL_EMEM, _("sl_trustfile")); … … 863 863 * R.W. Tue May 29 22:05:16 CEST 2001 864 864 */ 865 csym = malloc(MAXFILENAME );865 csym = calloc(1, MAXFILENAME ); 866 866 if (!csym) 867 867 { … … 886 886 } 887 887 888 full = malloc(MAXFILENAME );888 full = calloc(1, MAXFILENAME ); 889 889 if (!full) 890 890 { -
trunk/src/yulectl.c
r396 r454 591 591 } 592 592 size = strlen(clientcd) + 1 + strlen(CLIENT) + 6; 593 sockname = malloc (size);593 sockname = calloc(1,size); 594 594 if (!sockname) 595 595 {
Note:
See TracChangeset
for help on using the changeset viewer.