- Timestamp:
- Jan 7, 2019, 8:03:37 PM (6 years ago)
- Location:
- trunk/src
- Files:
-
- 18 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/cutest_sh_unix.c
r481 r539 21 21 char * area[256]; 22 22 23 #if !defined(USE_SYSTEM_MALLOC) && !defined(__clang__) 23 24 /* test reuse of last freed chunk */ 24 25 buf = malloc(1024); … … 28 29 CuAssertTrue(tc, buf == area[0]); 29 30 free(area[0]); 30 31 #endif 32 31 33 /* test realloc */ 32 34 buf = malloc(16); -
trunk/src/cutest_zAVLTree.c
r481 r539 513 513 514 514 zAVL_string_reset(ztest_tree); 515 ztest_tree = NULL; 515 516 str = zAVL_string_get(ztest_tree, "foo"); 516 517 CuAssertTrue(tc, str == NULL); -
trunk/src/samhain.c
r511 r539 348 348 sh_global_check_silent = 0; 349 349 sh_load_delta_flag = 0; 350 strcpy ( sh_sig_msg, _("None")); 350 sh_sig_msg[4] = '\0'; 351 sh_sig_msg[3] = 'e'; 352 sh_sig_msg[2] = 'n'; 353 sh_sig_msg[1] = 'o'; 354 sh_sig_msg[0] = 'N'; 351 355 352 356 #ifdef MKB_01 … … 877 881 if (NULL == (dp = opendir(_("/proc")))) 878 882 { 883 /* cppcheck-suppress resourceLeak */ 879 884 return NULL; 880 885 } -
trunk/src/sh_database.c
r481 r539 1411 1411 /*@-type@*//* byte* versus char[..] */ 1412 1412 if (attr_tab[i].inHash == 1 && 1413 ((char *)(db_entry)+attr_tab[i].off) != '\0')1413 *((char *)(db_entry)+attr_tab[i].off) != '\0') 1414 1414 { 1415 1415 (void)md5Update(&crc, -
trunk/src/sh_files.c
r516 r539 2046 2046 #endif 2047 2047 2048 /* This is the LCG from Numerical Recipies. Deterministic. 2049 */ 2050 static unsigned int simple_rand(unsigned int * state) 2051 { 2052 *state = 1664525 * (*state) + 1013904223; 2053 return *state; 2054 } 2055 2048 2056 void * sh_dummy_dirlist; 2049 2057 void * sh_dummy_tmpcat; … … 2290 2298 BREAKEXIT(sh_derr); 2291 2299 2292 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_RAND_R) 2293 if (0 == (rand_r(&state) % 5)) (void) sh_derr(); 2294 #else 2295 if (0 == state * (rand() % 5)) (void) sh_derr(); 2296 #endif 2300 if (0 == (simple_rand(&state) % 5)) (void) sh_derr(); 2297 2301 2298 2302 /* ---- Check the file. ---- … … 2637 2641 BREAKEXIT(sh_derr); 2638 2642 2639 #if defined(HAVE_PTHREAD) && defined (_POSIX_THREAD_SAFE_FUNCTIONS) && defined(HAVE_RAND_R) 2640 if (0 == (rand_r(&state) % 2)) (void) sh_derr(); 2641 #else 2642 if (0 == state * (rand() % 2)) (void) sh_derr(); 2643 #endif 2643 if (0 == (simple_rand(&state) % 2)) (void) sh_derr(); 2644 2644 2645 2645 if (dirName && infileName && (dirName[0] == '/') && (dirName[1] == '\0') -
trunk/src/sh_filetype.c
r481 r539 597 597 fprintf(stdout, "%s: %s\n", argv[1], filetype); 598 598 599 fclose(fh); 600 599 601 return 0; 600 602 } -
trunk/src/sh_getopt.c
r485 r539 418 418 419 419 #ifdef HAVE_LIBPRELUDE 420 if (num > 0) fputc ('\n', stdout); ++num;421 fputs (_(" prelude (0.9.6+)"), stdout); 420 if (num > 0) fputc ('\n', stdout); 421 fputs (_(" prelude (0.9.6+)"), stdout); ++num; 422 422 #endif 423 423 … … 635 635 { 636 636 fprintf (stdout, "%s", 637 _("Copyright (C) 1999-20 08Rainer Wichmann"\637 _("Copyright (C) 1999-2019 Rainer Wichmann"\ 638 638 " (http://la-samhna.de).\n\n")); 639 639 -
trunk/src/sh_ipvx.c
r526 r539 355 355 char hostbuf[SH_BUFSIZE]; 356 356 357 SL_ENTER(_("sh_ipvx_canonical")); 358 357 359 numeric[0] = '\0'; 358 360 … … 424 426 struct sockaddr_in *sin; 425 427 428 SL_ENTER(_("sh_ipvx_canonical")); 429 426 430 numeric[0] = '\0'; 427 431 … … 459 463 #endif 460 464 461 if (flag) 462 return out; 465 if (flag) { 466 SL_RETURN(out, _("sh_ipvx_canonical")); 467 } 463 468 464 469 if (out) … … 466 471 if (numeric[0] == '\0') 467 472 sl_strlcpy (numeric, _("0.0.0.0"), nlen); 468 return NULL;473 SL_RETURN(NULL, _("sh_ipvx_canonical")); 469 474 } 470 475 … … 505 510 struct addrinfo *p; 506 511 512 SL_ENTER(_("sh_ipvx_reverse_check_ok")); 513 507 514 sl_snprintf(sport, sizeof(sport), "%d", port); 508 515 … … 513 520 if (getaddrinfo(peer, sport, &hints, &res) != 0) 514 521 { 515 return 0;522 SL_RETURN((0), _("sh_ipvx_reverse_check_ok")); 516 523 } 517 524 … … 533 540 if (0 == sl_strcmp(dst1, dst2)) 534 541 { 535 return 1;542 SL_RETURN((1), _("sh_ipvx_reverse_check_ok")); 536 543 } 537 544 } … … 546 553 (void) port; 547 554 555 SL_ENTER(_("sh_ipvx_reverse_check_ok")); 556 548 557 he = sh_gethostbyname(peer); 549 558 if (he != NULL) … … 551 560 for (p = he->h_addr_list; *p; ++p) 552 561 { 553 if (0 == memcmp (*p, &(sin->sin_addr), sizeof(in_addr_t)) ) 554 return 1;562 if (0 == memcmp (*p, &(sin->sin_addr), sizeof(in_addr_t)) ) { 563 SL_RETURN((1), _("sh_ipvx_reverse_check_ok")); } 555 564 } 556 565 } 557 566 #endif 558 return 0;567 SL_RETURN((0), _("sh_ipvx_reverse_check_ok")); 559 568 } 560 569 -
trunk/src/sh_log_evalrule.c
r481 r539 458 458 { 459 459 *seconds = strtoul(splits[0], &endptr, 10); 460 if (( endptr == '\0' ||endptr != splits[0]) && (*seconds != ULONG_MAX))460 if ((*endptr == '\0') && (endptr != splits[0]) && (*seconds != ULONG_MAX)) 461 461 { 462 462 res = sh_util_strdup(splits[1]); … … 495 495 volatile char pflag = '-'; 496 496 497 if (s == NULL) 498 return -1; 499 /* cppcheck-suppress uninitdata */ 497 500 while ( *s && isspace((int)*s) ) ++s; 498 501 if (0 == strncmp(s, _("KEEP"), 4) || -
trunk/src/sh_portcheck.c
r530 r539 430 430 sl_fclose(FIL__, __LINE__, fp); 431 431 } 432 /* cppcheck-suppress resourceLeak */ 432 433 return NULL; 433 434 } … … 480 481 sl_fclose(FIL__, __LINE__, fp); 481 482 } 483 /* cppcheck-suppress resourceLeak */ 482 484 return NULL; 483 485 } -
trunk/src/sh_processcheck.c
r481 r539 787 787 /* sched_getparam() is broken on solaris 10, may segfault in librt 788 788 */ 789 #if !defined(sun) && !defined(__sun) && !defined(__sun__) 789 #if !defined(sun) && !defined(__sun) && !defined(__sun__) && !defined(__OpenBSD__) 790 790 #ifdef _POSIX_PRIORITY_SCHEDULING 791 791 if (0 == sched_getparam (pid, &p)) -
trunk/src/sh_registry.c
r481 r539 841 841 size_t len; 842 842 int retval = -1; 843 844 if (!subkey) 845 return 0; 843 846 844 847 len = strlen(path) + 1 + strlen(subkey) + 1; … … 934 937 { 935 938 HKEY topKey; 936 char * subkey ;939 char * subkey = NULL; 937 940 char path[20] = ""; 938 941 int pos = 0; … … 974 977 else 975 978 { 976 979 /* We bail out here if the topKey is undefined */ 977 980 char * tmp = sh_util_safe_name_keepspace(key); 978 981 size_t tlen = sl_strlen(tmp); … … 1003 1006 *************************/ 1004 1007 1008 /* Returns 0 if !subkey */ 1009 /* cppcheck-suppress uninitvar */ 1005 1010 return CheckThisSubkey (topKey, subkey, path, isSingle, 0); 1006 1011 } -
trunk/src/sh_static.c
r533 r539 1474 1474 *fp = fopen("/etc/config/hosts", "r"); 1475 1475 } 1476 /* cppcheck-suppress resourceLeak */ 1476 1477 return; 1477 1478 } … … 1549 1550 1550 1551 *h_errnop=HOST_NOT_FOUND; 1552 if (fp == NULL) { 1553 return ret; 1554 } 1551 1555 while (fgets(buf, buflen, fp)) { 1552 1556 if ((cp = strchr(buf, '#'))) -
trunk/src/sh_tiger0.c
r481 r539 1021 1021 /*@-bufferoverflowhigh -usedef@*/ 1022 1022 for (cnt = 0; cnt < 16; ++cnt) 1023 s printf (&outbuf[cnt*2], _("%02X"), /* known to fit */1024 (unsigned int) md5buffer[cnt]);1023 sl_snprintf (&outbuf[cnt*2], 3, _("%02X"), /* known to fit */ 1024 (unsigned int) md5buffer[cnt]); 1025 1025 /*@+bufferoverflowhigh +usedef@*/ 1026 1026 for (cnt = 32; cnt < KEY_LEN; ++cnt) … … 1585 1585 /*@-bufferoverflowhigh -usedef@*/ 1586 1586 for (cnt = 0; cnt < 20; ++cnt) 1587 s printf (&outbuf[cnt*2], _("%02X"), /* known to fit */1587 sl_snprintf (&outbuf[cnt*2], 3, _("%02X"), /* known to fit */ 1588 1588 (unsigned int) sha1buffer[cnt]); 1589 1589 /*@+bufferoverflowhigh +usedef@*/ -
trunk/src/sh_tools.c
r481 r539 188 188 if (-1 == (sd = socket(AF_INET, SOCK_STREAM, 0))) 189 189 { 190 /* cppcheck-suppress resourceLeak */ 190 191 return 0; 191 192 } … … 864 865 if (tools_debug) 865 866 fputs(_("-03- cached\n"), stderr); 867 /* cppcheck-suppress uninitStructMember */ 866 868 fd = socket(ss.ss_family, SOCK_STREAM, 0); 867 869 if (fd < 0) … … 879 881 if (fail != (-1)) 880 882 { 883 /* cppcheck-suppress uninitStructMember */ 881 884 int addrlen = SH_SS_LEN(ss); 882 885 883 886 if ( retry_connect(FIL__, __LINE__, fd, 884 887 sh_ipvx_sockaddr_cast(&ss), addrlen) < 0) -
trunk/src/sh_unix.c
r534 r539 2341 2341 hh = diff / 60; 2342 2342 mm = diff - (hh * 60); 2343 s printf (tz, _("%+03d%02d"), hh, mm); /* known to fit */2343 sl_snprintf (tz, sizeof(tz), _("%+03d%02d"), hh, mm); /* known to fit */ 2344 2344 } 2345 2345 else 2346 2346 { 2347 s printf (tz, _("%+03d%02d"), 0, 0);2347 sl_snprintf (tz, sizeof(tz), _("%+03d%02d"), 0, 0); 2348 2348 } 2349 2349 SL_RETURN(tz, _("t_zone")); … … 2483 2483 MSG_E_NET, errmsg, error_call, 2484 2484 _("time"), sh.srvtime.name); 2485 errflag = error_num; 2485 2486 fail = 1; 2486 2487 } … … 4602 4603 SL_ENTER(_("sh_unix_lock")); 4603 4604 4604 s printf (myPid, "%ld\n", (long) sh.pid); /* known to fit */4605 sl_snprintf (myPid, sizeof(myPid), "%ld\n", (long) sh.pid); /* known to fit */ 4605 4606 4606 4607 if (flag == NULL) /* PID file, check for directory */ -
trunk/src/sh_xfer_server.c
r491 r539 1068 1068 memcpy(&peer_addr, &(conn->addr_peer), sizeof(struct sh_sockaddr)); 1069 1069 sh_ipvx_ntoa (peer_ip, sizeof(peer_ip), &peer_addr); 1070 peer_name[0] = '\0'; 1070 1071 1071 1072 /* get canonical name of socket peer -
trunk/src/slib.c
r529 r539 1777 1777 free (ofiles[fd]); 1778 1778 ofiles[fd] = NULL; 1779 /* cppcheck-suppress memleak */ 1779 1780 SL_IRETURN(SL_EMEM, _("sl_make_ticket")); 1780 1781 } … … 1789 1790 (void) free (ofiles[fd]); 1790 1791 ofiles[fd] = NULL; 1792 /* cppcheck-suppress memleak */ 1791 1793 SL_IRETURN(ticket, _("sl_make_ticket")); 1792 1794 } … … 1802 1804 ofiles[fd]->oline = oline; 1803 1805 1806 /* cppcheck-suppress memleak */ 1804 1807 SL_IRETURN(ticket, _("sl_make_ticket")); 1805 1808 }
Note:
See TracChangeset
for help on using the changeset viewer.