Show
Ignore:
Timestamp:
2001-01-08 15:09:30 (8 years ago)
Author:
Thomas Roessler <roessler@…>
Branch:
HEAD
Message:

Let check_sec.sh check for use of the unsafe malloc, realloc, free,
and strdup routines. While we are on it, plug some memory leaks and
make some code understandable.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • check_sec.sh

    r2238 r2239  
    77TMPFILE="`mktemp check_sec.tmp.XXXXXX`" || exit 1 
    88 
    9 do_check () 
     9do_check_files () 
    1010{ 
    11         egrep -n "$1" *.c */*.c | fgrep -v $2 > $TMPFILE 
     11        pattern="$1" ; shift 
     12        magic="$1" ; shift 
     13        msg="$1" ; shift 
     14        egrep -n "$pattern" "$@"                | \ 
     15                grep -v '^[^     ]*:[^  ]*#'    | \ 
     16                fgrep -v "$magic" > $TMPFILE 
     17 
    1218        test -s $TMPFILE && { 
    13                 echo "$3" ; 
     19                echo "$msg" ; 
    1420                cat $TMPFILE; 
     21                rm -f $TMPFILE; 
    1522                exit 1; 
    1623        } 
    1724} 
    1825 
    19  
     26do_check () 
     27{ 
     28        do_check_files "$1" "$2" "$3" *.c */*.c 
     29} 
    2030 
    2131do_check '\<fopen.*'\"'.*w' __FOPEN_CHECKED__ "Alert: Unchecked fopen calls." 
    2232do_check '\<(mutt_)?strcpy' __STRCPY_CHECKED__ "Alert: Unchecked strcpy calls." 
    2333do_check '\<strcat' __STRCAT_CHECKED__ "Alert: Unchecked strcat calls." 
    24 do_check 'sprintf.*%s' __SPRINTF_CHECKED__ "Alert: Unchecked sprintf calls." 
     34do_check '\<sprintf.*%s' __SPRINTF_CHECKED__ "Alert: Unchecked sprintf calls." 
     35 
     36# don't do this check on others' code. 
     37do_check_files '\<(malloc|realloc|free|strdup)[         ]*\(' __MEM_CHECKED__ "Alert: Use of traditional memory management calls." \ 
     38        *.c imap/*.c 
    2539 
    2640rm -f $TMPFILE