Changeset 473 for trunk


Ignore:
Timestamp:
May 29, 2015, 10:42:18 PM (10 years ago)
Author:
katerina
Message:

Fix for ticket #371 (use cppcheck instead of uno for static checking).

Location:
trunk
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/docs/Changelog

    r472 r473  
    11
     2        * Modify testcompile.sh to remove 'uno' and use 'cppcheck'
     3          for static checking
    24        * Move AC_CHECK_FUNCS( getnameinfo getaddrinfo ) behind
    35          the check for libsocket to have them found on Solaris
  • trunk/src/samhain.c

    r454 r473  
    156156  ptr->g_glob     = calloc(1, SH_MAX_GLOBS * (GLOB_LEN+1));
    157157  if (!(ptr->g_glob))
    158     return -1;
     158    {
     159      free(ptr);
     160      return -1;
     161    }
    159162  return pthread_setspecific(g_key, ptr);
    160163}
  • trunk/src/sh_calls.c

    r472 r473  
    200200  error = errno;
    201201  if (val_retry != 0) {
    202     long eport;
     202    long eport = 0;
    203203    char eaddr[SH_IP_BUF];
    204204    char emesg[SH_BUFSIZE];
  • trunk/src/sh_entropy.c

    r460 r473  
    640640      }
    641641     
     642      /* cppcheck-suppress leakNoVarFunctionCall */
    642643      if (NULL != freopen (_("/dev/null"), "r+", stderr))
    643644        {
  • trunk/src/sh_html.c

    r454 r473  
    311311          if (entry_orig != NULL)
    312312            {
    313               entry_orig = realloc(entry_orig,           /* free() ok     */
     313              char * ptr = realloc(entry_orig,           /* free() ok     */
    314314                                   entry_size + line_size + 1);
    315               if (entry_orig) { add_size = line_size; }
     315              if (ptr) {
     316                entry_orig = ptr;
     317                add_size = line_size;
     318              } else {
     319                { free(entry_orig); entry_orig = NULL; }
     320              }
    316321            }
    317322          else
  • trunk/src/sh_portcheck.c

    r468 r473  
    16881688                                                 char * interface, int type)
    16891689{
    1690   char buf[256];
     1690  char buf[256] = { '\0' };
    16911691  int proto;
    16921692  char * p;
  • trunk/src/sh_srp.c

    r454 r473  
    114114      size = strlen(str) + 1;
    115115      if (size > siz_str_internal)
    116         get_str_internal = realloc (get_str_internal, size);
     116        {
     117          char * ptr = realloc (get_str_internal, size);
     118          if (ptr)
     119            get_str_internal = ptr;
     120          else
     121            { free(get_str_internal); get_str_internal = NULL; }
     122        }
    117123      if (get_str_internal == NULL)
    118124        {
  • trunk/src/sh_static.c

    r454 r473  
    16411641        ; /* 'label at end of compound statement' */
    16421642        SH_MUTEX_UNLOCK(resolv_lock);
     1643        /* cppcheck-suppress resourceLeak */
    16431644        return 0;
    16441645}
  • trunk/src/sh_unix.c

    r462 r473  
    15041504    if (env1[envlen] == NULL)
    15051505      {
     1506        int i;
    15061507        fprintf(stderr, _("%s: %d: Out of memory\n"), FIL__, __LINE__);
     1508        for (i = 0; i < envlen; ++i) free(env1[len]);
     1509        free(env1);
    15071510        SL_RET0(_("sh_unix_copyenv"));
    15081511      }
     
    56725675
    56735676  sigtrap_variables->not_traced = signum;
     5677  /* cppcheck-suppress memleak */
    56745678  return;
    56755679}
  • trunk/src/sh_utils.c

    r454 r473  
    13151315  while (0 < (ii = sl_read (fp, &image[s], 4096)))
    13161316    {
     1317      unsigned char * ptr;
    13171318      ilen += ii;
    13181319      s    += 4096;
    1319       image = realloc (image, (size_t) (4096 + s));
     1320      ptr = realloc (image, (size_t) (4096 + s));
     1321      if (ptr)
     1322        image = ptr;
     1323      else
     1324        { free(image); image = NULL; }
    13201325      if (!image)
    13211326        goto bail_mem;
  • trunk/src/slib.c

    r454 r473  
    17381738  /* Make entry.
    17391739   */
     1740  /* cppcheck-suppress arrayIndexOutOfBoundsCond */
    17401741  if (fd >= MAXFD || fd < 0)
    17411742     {
     
    20102011  /* Make entry.
    20112012   */
     2013  /* cppcheck-suppress arrayIndexOutOfBoundsCond */
    20122014  if (fd >= MAXFD)
    20132015     {
  • trunk/test/testcompile.sh

    r378 r473  
    2020#
    2121
    22 # dnmalloc + flawfinder + (36 * 3)
    23 MAXTEST=116; export MAXTEST
     22# dnmalloc + cppcheck + flawfinder + (38 * 2)
     23MAXTEST=79; export MAXTEST
    2424
    2525run_dnmalloc ()
     
    8383}
    8484
    85 run_uno ()
     85run_cppcheck ()
    8686{
    8787    if [ -z "$doall" ]; then
    88         [ -z "$quiet" ] && log_skip $2 ${MAXTEST} "$TEST (uno)";
     88        [ -z "$quiet" ] && log_skip $2 ${MAXTEST} "check w/cppcheck";
    8989        return 0
    9090    fi
    9191    #
    92     UNO=`find_path uno`
     92    CPC=`find_path cppcheck`
    9393    #
    94     if [ -z "$UNO" ]; then
    95         log_skip $num $MAXTEST 'check w/uno (not in PATH)'
     94    if [ -z "$CPC" ]; then
     95        log_skip $num ${MAXTEST} 'check w/cppcheck (not in PATH)'
    9696        return 0
    9797    fi
    9898    #
    9999    cd src/
    100     stat=`uno -DHAVE_MMAP=1 -DUSE_UNO=1 -t -I. -I.. -I../include sh_*.c samhain.c slib.c dnmalloc.c zAVLTree.c trustfile.c rijndael-*.c bignum.c 2>&1 | wc -l`
    101     if [ $stat -ne 1 ]; then
    102         uno -DSH_WITH_CLIENT -DSH_WITH_SERVER -DHAVE_MMAP=1 -DUSE_UNO=1 -t -I. -I.. -I../include sh_*.c samhain.c slib.c dnmalloc.c zAVLTree.c trustfile.c rijndael-*.c bignum.c >>../test_log 2>&1
     100    stat=`cppcheck --quiet --inline-suppr --force -j 4 --template="{file},{line},{severity},{id},{message}" -I. -I.. -I../include sh_*.c samhain.c slib.c dnmalloc.c zAVLTree.c trustfile.c rijndael-*.c bignum.c 2>&1 | wc -l`
     101    if [ $stat -ne 0 ]; then
     102        cppcheck --quiet --inline-suppr --force -j 4 --template="{file},{line},{severity},{id},{message}" -I. -I.. -I../include sh_*.c samhain.c slib.c dnmalloc.c zAVLTree.c trustfile.c rijndael-*.c bignum.c >>../test_log 2>&1
    103103        retval=1
    104         [ -z "$quiet" ] && log_fail $2 ${MAXTEST} "$TEST (uno)";
     104        [ -z "$quiet" ] && log_fail $2 ${MAXTEST} "check w/cppcheck";
    105105    else
    106106        retval=0
    107         [ -z "$quiet" ] &&     log_ok   $2 ${MAXTEST} "$TEST (uno)";
     107        [ -z "$quiet" ] &&     log_ok   $2 ${MAXTEST} "check w/cppcheck";
    108108    fi
    109109    cd ..
     
    303303
    304304        #
     305        # test dnmalloc
     306        #
     307        TEST="${S}check w/cppcheck${E}"
     308        #
     309        let "num = num + 1" >/dev/null
     310        #
     311        run_cppcheck 0 $num || let "numfail = numfail + 1"  >/dev/null
     312        #
     313
     314        #
    305315        # test flawfinder
    306316        #
     
    333343        let "num = num + 1" >/dev/null
    334344        run_smatch $? $num || let "numfail = numfail + 1"  >/dev/null
    335         let "num = num + 1" >/dev/null
    336         run_uno $? $num || let "numfail = numfail + 1"  >/dev/null
    337345
    338346        #
     
    353361        let "num = num + 1" >/dev/null
    354362        run_smatch $? $num || let "numfail = numfail + 1"  >/dev/null
    355         let "num = num + 1" >/dev/null
    356         run_uno $? $num || let "numfail = numfail + 1"  >/dev/null
    357363        #
    358364        [ -z "${SMATCH_CC}" ] || { CC="${SMATCH_CC}"; export CC; SMATCH="${SAVE_SMATCH}"; export SMATCH; }
     
    372378        let "num = num + 1" >/dev/null
    373379        run_smatch $? $num || let "numfail = numfail + 1"  >/dev/null
    374         let "num = num + 1" >/dev/null
    375         run_uno $? $num || let "numfail = numfail + 1"  >/dev/null
    376380
    377381        #
     
    392396        let "num = num + 1" >/dev/null
    393397        run_smatch $? $num || let "numfail = numfail + 1"  >/dev/null
    394         let "num = num + 1" >/dev/null
    395         run_uno $? $num || let "numfail = numfail + 1"  >/dev/null
    396398        #
    397399        [ -z "${SMATCH_CC}" ] || { CC="${SMATCH_CC}"; export CC; SMATCH="${SAVE_SMATCH}"; export SMATCH; }
     
    411413        let "num = num + 1" >/dev/null
    412414        run_smatch $? $num || let "numfail = numfail + 1"  >/dev/null
    413         let "num = num + 1" >/dev/null
    414         run_uno $? $num || let "numfail = numfail + 1"  >/dev/null
    415415
    416416        #
     
    429429        let "num = num + 1" >/dev/null
    430430        run_smatch $? $num || let "numfail = numfail + 1"  >/dev/null
    431         let "num = num + 1" >/dev/null
    432         run_uno $? $num || let "numfail = numfail + 1"  >/dev/null
    433431
    434432
     
    448446        let "num = num + 1" >/dev/null
    449447        run_smatch $? $num || let "numfail = numfail + 1"  >/dev/null
    450         let "num = num + 1" >/dev/null
    451         run_uno $? $num || let "numfail = numfail + 1"  >/dev/null
    452448
    453449        #
     
    466462        let "num = num + 1" >/dev/null
    467463        run_smatch $? $num || let "numfail = numfail + 1"  >/dev/null
    468         let "num = num + 1" >/dev/null
    469         run_uno $? $num || let "numfail = numfail + 1"  >/dev/null
    470464
    471465        #
     
    484478        let "num = num + 1" >/dev/null
    485479        run_smatch $? $num debug || let "numfail = numfail + 1"  >/dev/null
    486         let "num = num + 1" >/dev/null
    487         run_uno $? $num || let "numfail = numfail + 1"  >/dev/null
    488480
    489481        #
     
    509501            let "num = num + 1" >/dev/null
    510502            run_smatch $? $num || let "numfail = numfail + 1"  >/dev/null
    511             let "num = num + 1" >/dev/null
    512             run_uno $? $num || let "numfail = numfail + 1"  >/dev/null
    513503        fi
    514504
     
    528518        let "num = num + 1" >/dev/null
    529519        run_smatch $? $num || let "numfail = numfail + 1"  >/dev/null
    530         let "num = num + 1" >/dev/null
    531         run_uno $? $num || let "numfail = numfail + 1"  >/dev/null
    532520
    533521        #
     
    546534        let "num = num + 1" >/dev/null
    547535        run_smatch $? $num || let "numfail = numfail + 1"  >/dev/null
    548         let "num = num + 1" >/dev/null
    549         run_uno $? $num || let "numfail = numfail + 1"  >/dev/null
    550536
    551537        #
     
    564550        let "num = num + 1" >/dev/null
    565551        run_smatch $? $num || let "numfail = numfail + 1"  >/dev/null
    566         let "num = num + 1" >/dev/null
    567         run_uno $? $num || let "numfail = numfail + 1"  >/dev/null
    568552
    569553        #
     
    582566        let "num = num + 1" >/dev/null
    583567        run_smatch $? $num || let "numfail = numfail + 1"  >/dev/null
    584         let "num = num + 1" >/dev/null
    585         run_uno $? $num || let "numfail = numfail + 1"  >/dev/null
    586568
    587569        #
     
    600582        let "num = num + 1" >/dev/null
    601583        run_smatch $? $num || let "numfail = numfail + 1"  >/dev/null
    602         let "num = num + 1" >/dev/null
    603         run_uno $? $num || let "numfail = numfail + 1"  >/dev/null
    604584
    605585        #
     
    618598        let "num = num + 1" >/dev/null
    619599        run_smatch $? $num || let "numfail = numfail + 1"  >/dev/null
    620         let "num = num + 1" >/dev/null
    621         run_uno $? $num || let "numfail = numfail + 1"  >/dev/null
    622600
    623601        #
     
    636614        let "num = num + 1" >/dev/null
    637615        run_smatch $? $num || let "numfail = numfail + 1"  >/dev/null
    638         let "num = num + 1" >/dev/null
    639         run_uno $? $num || let "numfail = numfail + 1"  >/dev/null
    640616
    641617        #
     
    654630        let "num = num + 1" >/dev/null
    655631        run_smatch $? $num || let "numfail = numfail + 1"  >/dev/null
    656         let "num = num + 1" >/dev/null
    657         run_uno $? $num || let "numfail = numfail + 1"  >/dev/null
    658632
    659633        # echo; echo "${S}__ TEST CLIENT/SERVER __${E}"; echo;
     
    674648        let "num = num + 1" >/dev/null
    675649        run_smatch $? $num || let "numfail = numfail + 1"  >/dev/null
    676         let "num = num + 1" >/dev/null
    677         run_uno $? $num || let "numfail = numfail + 1"  >/dev/null
    678650       
    679651        if test -r "Makefile"; then
     
    687659        let "num = num + 1" >/dev/null
    688660        run_smatch $? $num || let "numfail = numfail + 1"  >/dev/null
    689         let "num = num + 1" >/dev/null
    690         run_uno $? $num || let "numfail = numfail + 1"  >/dev/null
    691661
    692662        #
     
    700670            let "num = num + 1" >/dev/null
    701671            [ -z "$quiet" ] && log_skip $num ${MAXTEST} "$TEST (smatch)";
    702             let "num = num + 1" >/dev/null
    703             [ -z "$quiet" ] && log_skip $num ${MAXTEST} "$TEST (uno)";
    704672
    705673            let "num = num + 1" >/dev/null
     
    707675            let "num = num + 1" >/dev/null
    708676            [ -z "$quiet" ] && log_skip $num ${MAXTEST} "$TEST (smatch)";
    709             let "num = num + 1" >/dev/null
    710             [ -z "$quiet" ] && log_skip $num ${MAXTEST} "$TEST (uno)";
    711677        else
    712678            if test -r "Makefile"; then
     
    720686            let "num = num + 1" >/dev/null
    721687            run_smatch $? $num || let "numfail = numfail + 1"  >/dev/null
    722             let "num = num + 1" >/dev/null
    723             run_uno $? $num || let "numfail = numfail + 1"  >/dev/null
    724688           
    725689            if test -r "Makefile"; then
     
    733697            let "num = num + 1" >/dev/null
    734698            run_smatch $? $num || let "numfail = numfail + 1"  >/dev/null
    735             let "num = num + 1" >/dev/null
    736             run_uno $? $num || let "numfail = numfail + 1"  >/dev/null
    737699            #
    738700        fi
     
    755717        let "num = num + 1" >/dev/null
    756718        run_smatch $? $num || let "numfail = numfail + 1"  >/dev/null
    757         let "num = num + 1" >/dev/null
    758         run_uno $? $num || let "numfail = numfail + 1"  >/dev/null
    759719       
    760720        if test -r "Makefile"; then
     
    768728        let "num = num + 1" >/dev/null
    769729        run_smatch $? $num || let "numfail = numfail + 1"  >/dev/null
    770         let "num = num + 1" >/dev/null
    771         run_uno $? $num || let "numfail = numfail + 1"  >/dev/null
    772730        #
    773731        [ -z "${SMATCH_CC}" ] || { CC="${SMATCH_CC}"; export CC; SMATCH="${SAVE_SMATCH}"; export SMATCH; }
     
    798756            let "num = num + 1" >/dev/null
    799757            run_smatch $? $num || let "numfail = numfail + 1"  >/dev/null
    800             let "num = num + 1" >/dev/null
    801             run_uno $? $num || let "numfail = numfail + 1"  >/dev/null
    802758            #
    803759            if test -r "Makefile"; then
     
    811767            let "num = num + 1" >/dev/null
    812768            run_smatch $? $num || let "numfail = numfail + 1"  >/dev/null
    813             let "num = num + 1" >/dev/null
    814             run_uno $? $num || let "numfail = numfail + 1"  >/dev/null
    815769        fi
    816770
     
    831785        let "num = num + 1" >/dev/null
    832786        run_smatch $? $num || let "numfail = numfail + 1"  >/dev/null
    833         let "num = num + 1" >/dev/null
    834         run_uno $? $num || let "numfail = numfail + 1"  >/dev/null
    835787        #
    836788        if test -r "Makefile"; then
     
    844796        let "num = num + 1" >/dev/null
    845797        run_smatch $? $num || let "numfail = numfail + 1"  >/dev/null
    846         let "num = num + 1" >/dev/null
    847         run_uno $? $num || let "numfail = numfail + 1"  >/dev/null
    848798
    849799        #
     
    862812        let "num = num + 1" >/dev/null
    863813        run_smatch $? $num debug || let "numfail = numfail + 1"  >/dev/null
    864         let "num = num + 1" >/dev/null
    865         run_uno $? $num || let "numfail = numfail + 1"  >/dev/null
    866814        #
    867815        if test -r "Makefile"; then
     
    875823        let "num = num + 1" >/dev/null
    876824        run_smatch $? $num debug || let "numfail = numfail + 1"  >/dev/null
    877         let "num = num + 1" >/dev/null
    878         run_uno $? $num || let "numfail = numfail + 1"  >/dev/null
    879825
    880826        #
     
    893839        let "num = num + 1" >/dev/null
    894840        run_smatch $? $num || let "numfail = numfail + 1"  >/dev/null
    895         let "num = num + 1" >/dev/null
    896         run_uno $? $num || let "numfail = numfail + 1"  >/dev/null
    897841        #
    898842        if test -r "Makefile"; then
     
    906850        let "num = num + 1" >/dev/null
    907851        run_smatch $? $num || let "numfail = numfail + 1"  >/dev/null
    908         let "num = num + 1" >/dev/null
    909         run_uno $? $num || let "numfail = numfail + 1"  >/dev/null
    910852
    911853        #
     
    924866        let "num = num + 1" >/dev/null
    925867        run_smatch $? $num || let "numfail = numfail + 1"  >/dev/null
    926         let "num = num + 1" >/dev/null
    927         run_uno $? $num || let "numfail = numfail + 1"  >/dev/null
    928868        #
    929869        if test -r "Makefile"; then
     
    937877        let "num = num + 1" >/dev/null
    938878        run_smatch $? $num || let "numfail = numfail + 1"  >/dev/null
    939         let "num = num + 1" >/dev/null
    940         run_uno $? $num || let "numfail = numfail + 1"  >/dev/null
    941879
    942880        #
     
    955893        let "num = num + 1" >/dev/null
    956894        run_smatch $? $num debug || let "numfail = numfail + 1"  >/dev/null
    957         let "num = num + 1" >/dev/null
    958         run_uno $? $num || let "numfail = numfail + 1"  >/dev/null
    959895        #
    960896        if test -r "Makefile"; then
     
    968904        let "num = num + 1" >/dev/null
    969905        run_smatch $? $num debug || let "numfail = numfail + 1"  >/dev/null
    970         let "num = num + 1" >/dev/null
    971         run_uno $? $num || let "numfail = numfail + 1"  >/dev/null
    972906
    973907        #
     
    986920        let "num = num + 1" >/dev/null
    987921        run_smatch $? $num || let "numfail = numfail + 1"  >/dev/null
    988         let "num = num + 1" >/dev/null
    989         run_uno $? $num || let "numfail = numfail + 1"  >/dev/null
    990922        #
    991923        if test -r "Makefile"; then
     
    999931        let "num = num + 1" >/dev/null
    1000932        run_smatch $? $num || let "numfail = numfail + 1"  >/dev/null
    1001         let "num = num + 1" >/dev/null
    1002         run_uno $? $num || let "numfail = numfail + 1"  >/dev/null
    1003933
    1004934        [ -z "${SMATCH}" ] || { CC="${SAVE_CC}"; export CC; }
Note: See TracChangeset for help on using the changeset viewer.