Flawfinder version 2.0.10, (C) 2001-2019 David A. Wheeler. Number of rules (primarily dangerous function names) in C/C++ ruleset: 223 Examining data/pmount-0.9.99-alpha/src/luks.h Examining data/pmount-0.9.99-alpha/src/conffile.c Examining data/pmount-0.9.99-alpha/src/loop.c Examining data/pmount-0.9.99-alpha/src/loop.h Examining data/pmount-0.9.99-alpha/src/utils.h Examining data/pmount-0.9.99-alpha/src/pmount.c Examining data/pmount-0.9.99-alpha/src/pumount.c Examining data/pmount-0.9.99-alpha/src/conffile.h Examining data/pmount-0.9.99-alpha/src/policy.h Examining data/pmount-0.9.99-alpha/src/fs.c Examining data/pmount-0.9.99-alpha/src/realpath.h Examining data/pmount-0.9.99-alpha/src/pmount-hal.c Examining data/pmount-0.9.99-alpha/src/configuration.c Examining data/pmount-0.9.99-alpha/src/policy.c Examining data/pmount-0.9.99-alpha/src/realpath.c Examining data/pmount-0.9.99-alpha/src/fs.h Examining data/pmount-0.9.99-alpha/src/utils.c Examining data/pmount-0.9.99-alpha/src/configuration.h Examining data/pmount-0.9.99-alpha/src/luks.c Examining data/pmount-0.9.99-alpha/tests/parse_cf.c Examining data/pmount-0.9.99-alpha/tests/test_spawn.c Examining data/pmount-0.9.99-alpha/tests/test_policy.c Examining data/pmount-0.9.99-alpha/tests/test_sysfs.c FINAL RESULTS: data/pmount-0.9.99-alpha/src/realpath.c:123:7: [5] (race) readlink: This accepts filename arguments; if an attacker can move those files or change the link content, a race condition results. Also, it does not terminate with ASCII NUL. (CWE-362, CWE-20). Reconsider approach. n = readlink(resolved_path, link_path, PATH_MAX); data/pmount-0.9.99-alpha/src/pmount.c:214:5: [4] (shell) execl: This causes a new program to execute and is difficult to use safely (CWE-78). try using a library call that implements the same functionality if available. execl( MOUNTPROG, MOUNTPROG, device, NULL ); data/pmount-0.9.99-alpha/src/pmount.c:333:7: [4] (format) snprintf: If format strings can be influenced by an attacker, they can be exploited, and note that sprintf variations do not always \0-terminate (CWE-134). Use a constant for the format specification. snprintf( fdmask_opt, sizeof( fdmask_opt ), fs->fdmask, data/pmount-0.9.99-alpha/src/pmount.c:373:4: [4] (format) snprintf: If format strings can be influenced by an attacker, they can be exploited, and note that sprintf variations do not always \0-terminate (CWE-134). Use a constant for the format specification. snprintf( iocharset_opt, sizeof( iocharset_opt ), data/pmount-0.9.99-alpha/src/pmount.c:382:7: [4] (format) snprintf: If format strings can be influenced by an attacker, they can be exploited, and note that sprintf variations do not always \0-terminate (CWE-134). Use a constant for the format specification. snprintf( iocharset_opt, sizeof( iocharset_opt ), data/pmount-0.9.99-alpha/src/pumount.c:124:9: [4] (shell) execl: This causes a new program to execute and is difficult to use safely (CWE-78). try using a library call that implements the same functionality if available. execl( UMOUNTPROG, UMOUNTPROG, "-l", device, NULL ); data/pmount-0.9.99-alpha/src/pumount.c:126:9: [4] (shell) execl: This causes a new program to execute and is difficult to use safely (CWE-78). try using a library call that implements the same functionality if available. execl( UMOUNTPROG, UMOUNTPROG, device, NULL ); data/pmount-0.9.99-alpha/src/utils.c:45:14: [4] (format) vprintf: If format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant for the format specification. result = vprintf( format, va ); data/pmount-0.9.99-alpha/src/utils.c:393:13: [4] (shell) execvp: This causes a new program to execute and is difficult to use safely (CWE-78). try using a library call that implements the same functionality if available. execvp( path, argv ); data/pmount-0.9.99-alpha/src/utils.c:395:13: [4] (shell) execv: This causes a new program to execute and is difficult to use safely (CWE-78). try using a library call that implements the same functionality if available. execv( path, argv ); data/pmount-0.9.99-alpha/src/utils.c:454:5: [4] (format) snprintf: If format strings can be influenced by an attacker, they can be exploited, and note that sprintf variations do not always \0-terminate (CWE-134). Use a constant for the format specification. snprintf( name, sizeof( name ), template, dir_fname ); data/pmount-0.9.99-alpha/src/pmount-hal.c:72:14: [3] (buffer) realpath: This function does not protect against buffer overflows, and some implementations can overflow internally (CWE-120/CWE-785!). Ensure that the destination buffer is at least of size MAXPATHLEN, andto protect against implementation problems, the input argument should also be checked to ensure it is no larger than MAXPATHLEN. if( !realpath( mntpt, realp ) ) data/pmount-0.9.99-alpha/src/pmount-hal.c:211:9: [3] (buffer) getenv: Environment variables are untrustable input if they can be set by an attacker. They can have any content and length, and the same variable can be set more than once (CWE-807, CWE-20). Check environment variables carefully before using them. if (getenv ("PMOUNT_DEBUG")) data/pmount-0.9.99-alpha/src/pmount.c:735:26: [3] (buffer) getopt_long: Some older implementations do not protect against internal buffer overflows (CWE-120, CWE-20). Check implementation on installation, or limit the size of all string inputs. switch( option = getopt_long( argc, argv, "+hdelFLsArwp:t:c:u:V", data/pmount-0.9.99-alpha/src/pmount.c:816:9: [3] (buffer) realpath: This function does not protect against buffer overflows, and some implementations can overflow internally (CWE-120/CWE-785!). Ensure that the destination buffer is at least of size MAXPATHLEN, andto protect against implementation problems, the input argument should also be checked to ensure it is no larger than MAXPATHLEN. if( realpath( devarg, device ) ) { data/pmount-0.9.99-alpha/src/pmount.c:861:19: [3] (buffer) realpath: This function does not protect against buffer overflows, and some implementations can overflow internally (CWE-120/CWE-785!). Ensure that the destination buffer is at least of size MAXPATHLEN, andto protect against implementation problems, the input argument should also be checked to ensure it is no larger than MAXPATHLEN. if ( !realpath( d, device ) ) { data/pmount-0.9.99-alpha/src/policy.c:311:14: [3] (buffer) realpath: This function does not protect against buffer overflows, and some implementations can overflow internally (CWE-120/CWE-785!). Ensure that the destination buffer is at least of size MAXPATHLEN, andto protect against implementation problems, the input argument should also be checked to ensure it is no larger than MAXPATHLEN. if(! realpath(devfilename, link)) { data/pmount-0.9.99-alpha/src/policy.c:351:8: [3] (buffer) realpath: This function does not protect against buffer overflows, and some implementations can overflow internally (CWE-120/CWE-785!). Ensure that the destination buffer is at least of size MAXPATHLEN, andto protect against implementation problems, the input argument should also be checked to ensure it is no larger than MAXPATHLEN. if(! realpath(path, full_device)) { data/pmount-0.9.99-alpha/src/policy.c:416:9: [3] (buffer) realpath: This function does not protect against buffer overflows, and some implementations can overflow internally (CWE-120/CWE-785!). Ensure that the destination buffer is at least of size MAXPATHLEN, andto protect against implementation problems, the input argument should also be checked to ensure it is no larger than MAXPATHLEN. if( realpath( device, pathbuf_arg ) ) data/pmount-0.9.99-alpha/src/policy.c:427:13: [3] (buffer) realpath: This function does not protect against buffer overflows, and some implementations can overflow internally (CWE-120/CWE-785!). Ensure that the destination buffer is at least of size MAXPATHLEN, andto protect against implementation problems, the input argument should also be checked to ensure it is no larger than MAXPATHLEN. if( realpath( fstab_device, pathbuf ) ) data/pmount-0.9.99-alpha/src/policy.c:473:9: [3] (buffer) realpath: This function does not protect against buffer overflows, and some implementations can overflow internally (CWE-120/CWE-785!). Ensure that the destination buffer is at least of size MAXPATHLEN, andto protect against implementation problems, the input argument should also be checked to ensure it is no larger than MAXPATHLEN. if( realpath( mntpt, realmntptbuf ) ) data/pmount-0.9.99-alpha/src/policy.c:485:13: [3] (buffer) realpath: This function does not protect against buffer overflows, and some implementations can overflow internally (CWE-120/CWE-785!). Ensure that the destination buffer is at least of size MAXPATHLEN, andto protect against implementation problems, the input argument should also be checked to ensure it is no larger than MAXPATHLEN. if( realpath( entry->mnt_dir, fstabmntptbuf ) ) data/pmount-0.9.99-alpha/src/policy.c:625:11: [3] (buffer) realpath: This function does not protect against buffer overflows, and some implementations can overflow internally (CWE-120/CWE-785!). Ensure that the destination buffer is at least of size MAXPATHLEN, andto protect against implementation problems, the input argument should also be checked to ensure it is no larger than MAXPATHLEN. if( realpath(d, full_path)) { data/pmount-0.9.99-alpha/src/pumount.c:84:17: [3] (buffer) realpath: This function does not protect against buffer overflows, and some implementations can overflow internally (CWE-120/CWE-785!). Ensure that the destination buffer is at least of size MAXPATHLEN, andto protect against implementation problems, the input argument should also be checked to ensure it is no larger than MAXPATHLEN. if( NULL == realpath( MEDIADIR, mediadir ) ) { data/pmount-0.9.99-alpha/src/pumount.c:205:26: [3] (buffer) getopt_long: Some older implementations do not protect against internal buffer overflows (CWE-120, CWE-20). Check implementation on installation, or limit the size of all string inputs. switch( option = getopt_long( argc, argv, "+hdluV", long_opts, NULL ) ) { data/pmount-0.9.99-alpha/src/pumount.c:258:9: [3] (buffer) realpath: This function does not protect against buffer overflows, and some implementations can overflow internally (CWE-120/CWE-785!). Ensure that the destination buffer is at least of size MAXPATHLEN, andto protect against implementation problems, the input argument should also be checked to ensure it is no larger than MAXPATHLEN. if( realpath( argv[optind], device ) ) { data/pmount-0.9.99-alpha/src/pumount.c:280:19: [3] (buffer) realpath: This function does not protect against buffer overflows, and some implementations can overflow internally (CWE-120/CWE-785!). Ensure that the destination buffer is at least of size MAXPATHLEN, andto protect against implementation problems, the input argument should also be checked to ensure it is no larger than MAXPATHLEN. if ( !realpath( d, device ) ) { data/pmount-0.9.99-alpha/src/realpath.h:14:8: [3] (buffer) realpath: This function does not protect against buffer overflows, and some implementations can overflow internally (CWE-120/CWE-785!). Ensure that the destination buffer is at least of size MAXPATHLEN, andto protect against implementation problems, the input argument should also be checked to ensure it is no larger than MAXPATHLEN. #ifdef realpath data/pmount-0.9.99-alpha/src/realpath.h:15:8: [3] (buffer) realpath: This function does not protect against buffer overflows, and some implementations can overflow internally (CWE-120/CWE-785!). Ensure that the destination buffer is at least of size MAXPATHLEN, andto protect against implementation problems, the input argument should also be checked to ensure it is no larger than MAXPATHLEN. #undef realpath data/pmount-0.9.99-alpha/src/realpath.h:17:9: [3] (buffer) realpath: This function does not protect against buffer overflows, and some implementations can overflow internally (CWE-120/CWE-785!). Ensure that the destination buffer is at least of size MAXPATHLEN, andto protect against implementation problems, the input argument should also be checked to ensure it is no larger than MAXPATHLEN. #define realpath(a,b) private_realpath(a,b,PATH_MAX) data/pmount-0.9.99-alpha/src/conffile.c:536:3: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char buffer[1024]; /* To trim the string */ data/pmount-0.9.99-alpha/src/conffile.c:548:3: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char buffer[1024]; /* To trim the string */ data/pmount-0.9.99-alpha/src/conffile.c:691:3: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char line_buffer[1000]; data/pmount-0.9.99-alpha/src/configuration.c:83:7: [2] (misc) fopen: Check when opening files - can an attacker redirect it (via symlinks), force the opening of special file type (e.g., device files), move things around to create a race condition, control its ancestors, or change its contents? (CWE-362). f = fopen(file,"r"); data/pmount-0.9.99-alpha/src/loop.c:91:3: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char buffer[1024]; data/pmount-0.9.99-alpha/src/loop.c:95:8: [2] (misc) open: Check when opening files - can an attacker redirect it (via symlinks), force the opening of special file type (e.g., device files), move things around to create a race condition, control its ancestors, or change its contents? (CWE-362). fd = open(source, O_RDWR); data/pmount-0.9.99-alpha/src/luks.c:110:5: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char path[PATH_MAX]; data/pmount-0.9.99-alpha/src/luks.c:138:3: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char path[PATH_MAX]; data/pmount-0.9.99-alpha/src/luks.c:159:3: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char path[PATH_MAX]; data/pmount-0.9.99-alpha/src/luks.c:175:3: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char path[PATH_MAX]; data/pmount-0.9.99-alpha/src/pmount-hal.c:65:5: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char realp[PATH_MAX]; data/pmount-0.9.99-alpha/src/pmount-hal.c:95:5: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char mntpt[PATH_MAX]; data/pmount-0.9.99-alpha/src/pmount-hal.c:120:5: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char freelabel[PATH_MAX]; data/pmount-0.9.99-alpha/src/pmount.c:248:5: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char ugid_opt[100]; data/pmount-0.9.99-alpha/src/pmount.c:249:5: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char umask_opt[100]; data/pmount-0.9.99-alpha/src/pmount.c:250:5: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char fdmask_opt[100]; data/pmount-0.9.99-alpha/src/pmount.c:251:5: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char iocharset_opt[100]; data/pmount-0.9.99-alpha/src/pmount.c:256:5: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char options[1000]; data/pmount-0.9.99-alpha/src/pmount.c:484:5: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char lockdirpath[PATH_MAX]; data/pmount-0.9.99-alpha/src/pmount.c:485:5: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char lockfilepath[PATH_MAX]; data/pmount-0.9.99-alpha/src/pmount.c:507:15: [2] (misc) open: Check when opening files - can an attacker redirect it (via symlinks), force the opening of special file type (e.g., device files), move things around to create a race condition, control its ancestors, or change its contents? (CWE-362). pidlock = open( lockfilepath, O_WRONLY|O_CREAT, 0644 ); data/pmount-0.9.99-alpha/src/pmount.c:530:5: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char lockdirpath[PATH_MAX]; data/pmount-0.9.99-alpha/src/pmount.c:531:5: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char lockfilepath[PATH_MAX]; data/pmount-0.9.99-alpha/src/pmount.c:610:5: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char lockdirpath[PATH_MAX]; data/pmount-0.9.99-alpha/src/pmount.c:611:5: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char lockfilepath[PATH_MAX]; data/pmount-0.9.99-alpha/src/pmount.c:656:5: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char mntpt[MEDIA_STRING_SIZE]; data/pmount-0.9.99-alpha/src/pmount.c:657:5: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char device[PATH_MAX], mntptdev[PATH_MAX]; data/pmount-0.9.99-alpha/src/pmount.c:658:5: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char decrypted_device[PATH_MAX]; data/pmount-0.9.99-alpha/src/pmount.c:859:13: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char d[PATH_MAX]; data/pmount-0.9.99-alpha/src/pmount.c:935:15: [2] (misc) open: Check when opening files - can an attacker redirect it (via symlinks), force the opening of special file type (e.g., device files), move things around to create a race condition, control its ancestors, or change its contents? (CWE-362). int fd = open(device, O_RDONLY); data/pmount-0.9.99-alpha/src/policy.c:90:5: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char blockdirname[255]; data/pmount-0.9.99-alpha/src/policy.c:91:5: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char devdirname[512]; // < 255 chars blockdir + max. 255 chars subdir data/pmount-0.9.99-alpha/src/policy.c:92:5: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char devfilename[PATH_MAX]; data/pmount-0.9.99-alpha/src/policy.c:233:5: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char path[PATH_MAX]; data/pmount-0.9.99-alpha/src/policy.c:240:9: [2] (misc) fopen: Check when opening files - can an attacker redirect it (via symlinks), force the opening of special file type (e.g., device files), move things around to create a race condition, control its ancestors, or change its contents? (CWE-362). f = fopen( path, "r" ); data/pmount-0.9.99-alpha/src/policy.c:294:5: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char link[PATH_MAX]; data/pmount-0.9.99-alpha/src/policy.c:295:5: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char path[PATH_MAX]; data/pmount-0.9.99-alpha/src/policy.c:296:5: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char devfilename[PATH_MAX]; data/pmount-0.9.99-alpha/src/policy.c:336:3: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char path[1024]; data/pmount-0.9.99-alpha/src/policy.c:337:3: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char full_device[1024]; data/pmount-0.9.99-alpha/src/policy.c:402:5: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char pathbuf[PATH_MAX]; data/pmount-0.9.99-alpha/src/policy.c:403:5: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char pathbuf_arg[PATH_MAX]; data/pmount-0.9.99-alpha/src/policy.c:404:12: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. static char fstab_device[PATH_MAX]; data/pmount-0.9.99-alpha/src/policy.c:411:16: [2] (misc) fopen: Check when opening files - can an attacker redirect it (via symlinks), force the opening of special file type (e.g., device files), move things around to create a race condition, control its ancestors, or change its contents? (CWE-362). if( !( f = fopen( fname, "r" ) ) ) { data/pmount-0.9.99-alpha/src/policy.c:445:32: [2] (integer) atoi: Unless checked, the resulting number can exceed the expected range (CWE-190). If source untrusted, check both minimum and maximum, even if the input had no minus sign (large numbers can roll over into negative number; consider saving to an unsigned value if that is intended). *uid = atoi( uidopt ); data/pmount-0.9.99-alpha/src/policy.c:468:5: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char realmntptbuf[PATH_MAX]; data/pmount-0.9.99-alpha/src/policy.c:469:5: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char fstabmntptbuf[PATH_MAX]; data/pmount-0.9.99-alpha/src/policy.c:478:16: [2] (misc) fopen: Check when opening files - can an attacker redirect it (via symlinks), force the opening of special file type (e.g., device files), move things around to create a race condition, control its ancestors, or change its contents? (CWE-362). if( !( f = fopen( fname, "r" ) ) ) { data/pmount-0.9.99-alpha/src/policy.c:505:5: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char mp[MEDIA_STRING_SIZE]; data/pmount-0.9.99-alpha/src/policy.c:530:3: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char blockdevpath[PATH_MAX]; data/pmount-0.9.99-alpha/src/policy.c:582:5: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char line[1024]; data/pmount-0.9.99-alpha/src/policy.c:583:5: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char full_path[1024]; data/pmount-0.9.99-alpha/src/policy.c:592:11: [2] (misc) fopen: Check when opening files - can an attacker redirect it (via symlinks), force the opening of special file type (e.g., device files), move things around to create a race condition, control its ancestors, or change its contents? (CWE-362). fwl = fopen( WHITELIST, "r" ); data/pmount-0.9.99-alpha/src/policy.c:646:5: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char lockdirname[PATH_MAX]; data/pmount-0.9.99-alpha/src/policy.c:661:3: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char fstab_device[PATH_MAX]; data/pmount-0.9.99-alpha/src/policy.c:723:3: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char pathbuf[PATH_MAX]; data/pmount-0.9.99-alpha/src/policy.c:726:3: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char name[MEDIA_STRING_SIZE], dir[MEDIA_STRING_SIZE], data/pmount-0.9.99-alpha/src/policy.c:757:3: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char username[100]; data/pmount-0.9.99-alpha/src/pumount.c:36:8: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. static char mntpt[MEDIA_STRING_SIZE]; data/pmount-0.9.99-alpha/src/pumount.c:69:5: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char mediadir[PATH_MAX]; data/pmount-0.9.99-alpha/src/pumount.c:165:5: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char device[PATH_MAX], mntptdev[PATH_MAX], path[PATH_MAX]; data/pmount-0.9.99-alpha/src/pumount.c:167:5: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char fstab_mntpt[MEDIA_STRING_SIZE]; data/pmount-0.9.99-alpha/src/pumount.c:278:13: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char d[PATH_MAX]; data/pmount-0.9.99-alpha/src/realpath.c:64:2: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char link_path[PATH_MAX+1]; data/pmount-0.9.99-alpha/src/realpath.c:147:4: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy(buf, link_path, n); data/pmount-0.9.99-alpha/src/realpath.c:148:4: [2] (buffer) memcpy: Does not check for buffer overflows when copying to destination (CWE-120). Make sure destination can always hold the source data. memcpy(buf + n, path, m + 1); data/pmount-0.9.99-alpha/src/utils.c:73:5: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char buf[100]; data/pmount-0.9.99-alpha/src/utils.c:78:9: [2] (misc) fopen: Check when opening files - can an attacker redirect it (via symlinks), force the opening of special file type (e.g., device files), move things around to create a race condition, control its ancestors, or change its contents? (CWE-362). f = fopen( file, "r" ); data/pmount-0.9.99-alpha/src/utils.c:103:5: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char stampfname[PATH_MAX]; data/pmount-0.9.99-alpha/src/utils.c:124:25: [2] (misc) open: Check when opening files - can an attacker redirect it (via symlinks), force the opening of special file type (e.g., device files), move things around to create a race condition, control its ancestors, or change its contents? (CWE-362). stampfile = open( stampfname, O_CREAT|O_WRONLY|O_EXCL, 0600 ); data/pmount-0.9.99-alpha/src/utils.c:201:5: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char stampfile[PATH_MAX]; data/pmount-0.9.99-alpha/src/utils.c:327:1: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char slurp_buffer[2048]; data/pmount-0.9.99-alpha/src/utils.c:373:16: [2] (misc) open: Check when opening files - can an attacker redirect it (via symlinks), force the opening of special file type (e.g., device files), move things around to create a race condition, control its ancestors, or change its contents? (CWE-362). devnull = open( "/dev/null", O_WRONLY ); data/pmount-0.9.99-alpha/src/utils.c:447:12: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. static char name[PATH_MAX]; data/pmount-0.9.99-alpha/src/utils.c:490:9: [2] (misc) open: Check when opening files - can an attacker redirect it (via symlinks), force the opening of special file type (e.g., device files), move things around to create a race condition, control its ancestors, or change its contents? (CWE-362). f = open( lockfile, O_WRONLY); data/pmount-0.9.99-alpha/tests/parse_cf.c:37:14: [2] (misc) fopen: Check when opening files - can an attacker redirect it (via symlinks), force the opening of special file type (e.g., device files), move things around to create a race condition, control its ancestors, or change its contents? (CWE-362). FILE * f = fopen("parse_cf.conf", "r"); data/pmount-0.9.99-alpha/tests/test_sysfs.c:45:3: [2] (buffer) char: Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues (CWE-119!/CWE-120). Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length. char device_path[512]; data/pmount-0.9.99-alpha/src/conffile.c:225:9: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). l = strlen(spec->base); data/pmount-0.9.99-alpha/src/conffile.c:226:14: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). l2 = l + strlen("_allow") +1; data/pmount-0.9.99-alpha/src/conffile.c:233:14: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). l2 = l + strlen("_allow_user") +1; data/pmount-0.9.99-alpha/src/conffile.c:240:14: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). l2 = l + strlen("_allow_group") +1; data/pmount-0.9.99-alpha/src/conffile.c:247:14: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). l2 = l + strlen("_deny_user") +1; data/pmount-0.9.99-alpha/src/conffile.c:338:11: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). len = strlen(dest); data/pmount-0.9.99-alpha/src/conffile.c:526:14: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). size_t l = strlen(source); data/pmount-0.9.99-alpha/src/fs.h:27:15: [1] (access) umask: Ensure that umask is given most restrictive possible setting (e.g., 066 or 077) (CWE-732). const char* umask; data/pmount-0.9.99-alpha/src/loop.c:46:8: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). if(strlen(*devices) > 0) { data/pmount-0.9.99-alpha/src/pmount-hal.c:100:9: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy( result, label, result_size-1 ); data/pmount-0.9.99-alpha/src/pmount-hal.c:116:9: [1] (access) umask: Ensure that umask is given most restrictive possible setting (e.g., 066 or 077) (CWE-732). umask, const char *fmask, const char *dmask, const char* iocharset, int addargc, const char* const* addargv ) data/pmount-0.9.99-alpha/src/pmount-hal.c:137:9: [1] (access) umask: Ensure that umask is given most restrictive possible setting (e.g., 066 or 077) (CWE-732). if( umask ) { data/pmount-0.9.99-alpha/src/pmount-hal.c:139:24: [1] (access) umask: Ensure that umask is given most restrictive possible setting (e.g., 066 or 077) (CWE-732). argv[argc++] = umask; data/pmount-0.9.99-alpha/src/pmount-hal.c:373:27: [1] (access) umask: Ensure that umask is given most restrictive possible setting (e.g., 066 or 077) (CWE-732). debug( "umask: %s\n", umask ); data/pmount-0.9.99-alpha/src/pmount-hal.c:408:62: [1] (access) umask: Ensure that umask is given most restrictive possible setting (e.g., 066 or 077) (CWE-732). exec_pmount( device, fstype, label, sync, noatime, exec, umask, fmask, dmask, iocharset, argc-2, argv+2 ); data/pmount-0.9.99-alpha/src/pmount.c:155:25: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). int media_dir_len = strlen( MEDIADIR ); data/pmount-0.9.99-alpha/src/pmount.c:166:13: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). if( strlen( label ) > MAX_LABEL_SIZE ) { data/pmount-0.9.99-alpha/src/pmount.c:178:13: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). if( strlen( device ) > MAX_LABEL_SIZE ) { data/pmount-0.9.99-alpha/src/pmount.c:244:16: [1] (access) umask: Ensure that umask is given most restrictive possible setting (e.g., 066 or 077) (CWE-732). const char* umask, const char *fmask, const char *dmask, data/pmount-0.9.99-alpha/src/pmount.c:273:9: [1] (access) umask: Ensure that umask is given most restrictive possible setting (e.g., 066 or 077) (CWE-732). if( umask && parse_unsigned( umask, E_ARGS ) > 0777 ) { data/pmount-0.9.99-alpha/src/pmount.c:273:34: [1] (access) umask: Ensure that umask is given most restrictive possible setting (e.g., 066 or 077) (CWE-732). if( umask && parse_unsigned( umask, E_ARGS ) > 0777 ) { data/pmount-0.9.99-alpha/src/pmount.c:274:58: [1] (access) umask: Ensure that umask is given most restrictive possible setting (e.g., 066 or 077) (CWE-732). fprintf( stderr, _("Error: invalid umask %s\n"), umask ); data/pmount-0.9.99-alpha/src/pmount.c:310:13: [1] (access) umask: Ensure that umask is given most restrictive possible setting (e.g., 066 or 077) (CWE-732). if( fs->umask ) data/pmount-0.9.99-alpha/src/pmount.c:312:3: [1] (access) umask: Ensure that umask is given most restrictive possible setting (e.g., 066 or 077) (CWE-732). umask ? umask : fs->umask ); data/pmount-0.9.99-alpha/src/pmount.c:312:11: [1] (access) umask: Ensure that umask is given most restrictive possible setting (e.g., 066 or 077) (CWE-732). umask ? umask : fs->umask ); data/pmount-0.9.99-alpha/src/pmount.c:312:23: [1] (access) umask: Ensure that umask is given most restrictive possible setting (e.g., 066 or 077) (CWE-732). umask ? umask : fs->umask ); data/pmount-0.9.99-alpha/src/pmount.c:316:13: [1] (access) umask: Ensure that umask is given most restrictive possible setting (e.g., 066 or 077) (CWE-732). if( fs->umask && fs->fdmask ) { data/pmount-0.9.99-alpha/src/pmount.c:318:10: [1] (access) umask: Ensure that umask is given most restrictive possible setting (e.g., 066 or 077) (CWE-732). if(umask) data/pmount-0.9.99-alpha/src/pmount.c:319:28: [1] (access) umask: Ensure that umask is given most restrictive possible setting (e.g., 066 or 077) (CWE-732). i_umask = parse_unsigned( umask, E_ARGS ); /* shouldn't fail */ data/pmount-0.9.99-alpha/src/pmount.c:321:32: [1] (access) umask: Ensure that umask is given most restrictive possible setting (e.g., 066 or 077) (CWE-732). i_umask = parse_unsigned( fs->umask, E_ARGS ); /* shouldn't fail */ data/pmount-0.9.99-alpha/src/pmount.c:418:21: [1] (access) umask: Ensure that umask is given most restrictive possible setting (e.g., 066 or 077) (CWE-732). const char* umask, const char *fmask, const char *dmask ) data/pmount-0.9.99-alpha/src/pmount.c:440:35: [1] (access) umask: Ensure that umask is given most restrictive possible setting (e.g., 066 or 077) (CWE-732). force_write, iocharset, utf8, umask, fmask, data/pmount-0.9.99-alpha/src/pmount.c:462:35: [1] (access) umask: Ensure that umask is given most restrictive possible setting (e.g., 066 or 077) (CWE-732). force_write, iocharset, utf8, umask, fmask, dmask, nostderr ); data/pmount-0.9.99-alpha/src/pmount.c:469:32: [1] (access) umask: Ensure that umask is given most restrictive possible setting (e.g., 066 or 077) (CWE-732). force_write, NULL, utf8, umask, fmask, dmask, nostderr ); data/pmount-0.9.99-alpha/src/pmount.c:998:29: [1] (access) umask: Ensure that umask is given most restrictive possible setting (e.g., 066 or 077) (CWE-732). iocharset, utf8, umask, data/pmount-0.9.99-alpha/src/pmount.c:1003:27: [1] (access) umask: Ensure that umask is given most restrictive possible setting (e.g., 066 or 077) (CWE-732). iocharset, utf8, umask, data/pmount-0.9.99-alpha/src/policy.c:607:13: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). if( strlen( line ) == sizeof( line ) - 1 ) { data/pmount-0.9.99-alpha/src/pumount.c:91:35: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). if( strncmp( mntpt, mediadir, strlen( mediadir ) ) ) { data/pmount-0.9.99-alpha/src/realpath.c:77:13: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). npath += strlen(npath); data/pmount-0.9.99-alpha/src/realpath.c:143:8: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). m = strlen(path); data/pmount-0.9.99-alpha/src/utils.c:405:13: [1] (buffer) read: Check buffer boundaries if used in a loop including recursive loops (CWE-120, CWE-20). nb_read = read(fds[0], slurp_buffer + slurp_size, data/pmount-0.9.99-alpha/src/utils.c:451:9: [1] (buffer) strlen: Does not handle strings that are not \0-terminated; if given one it may perform an over-read (it could cause a crash if unprotected) (CWE-126). if( strlen( dir ) >= sizeof( name ) - sizeof( template )) data/pmount-0.9.99-alpha/tests/test_policy.c:25:27: [1] (buffer) equal: Function does not check the second iterator for over-read conditions (CWE-126). This function is often discouraged by most C++ coding standards in favor of its safer alternatives provided since C++14. Consider using a form of this function that checks the second iterator before potentially overflowing it. const char *str2, int equal) data/pmount-0.9.99-alpha/tests/test_policy.c:33:8: [1] (buffer) equal: Function does not check the second iterator for over-read conditions (CWE-126). This function is often discouraged by most C++ coding standards in favor of its safer alternatives provided since C++14. Consider using a form of this function that checks the second iterator before potentially overflowing it. if(equal) data/pmount-0.9.99-alpha/tests/test_policy.c:42:10: [1] (buffer) equal: Function does not check the second iterator for over-read conditions (CWE-126). This function is often discouraged by most C++ coding standards in favor of its safer alternatives provided since C++14. Consider using a form of this function that checks the second iterator before potentially overflowing it. if(! equal) data/pmount-0.9.99-alpha/tests/test_policy.c:51:8: [1] (buffer) equal: Function does not check the second iterator for over-read conditions (CWE-126). This function is often discouraged by most C++ coding standards in favor of its safer alternatives provided since C++14. Consider using a form of this function that checks the second iterator before potentially overflowing it. if(equal) data/pmount-0.9.99-alpha/tests/test_policy.c:60:6: [1] (buffer) equal: Function does not check the second iterator for over-read conditions (CWE-126). This function is often discouraged by most C++ coding standards in favor of its safer alternatives provided since C++14. Consider using a form of this function that checks the second iterator before potentially overflowing it. if(equal) { ANALYSIS SUMMARY: Hits = 154 Lines analyzed = 5428 in approximately 0.18 seconds (29754 lines/second) Physical Source Lines of Code (SLOC) = 3434 Hits@level = [0] 169 [1] 47 [2] 77 [3] 19 [4] 10 [5] 1 Hits@level+ = [0+] 323 [1+] 154 [2+] 107 [3+] 30 [4+] 11 [5+] 1 Hits/KSLOC@level+ = [0+] 94.0594 [1+] 44.8457 [2+] 31.159 [3+] 8.73617 [4+] 3.20326 [5+] 0.291206 Dot directories skipped = 1 (--followdotdir overrides) Minimum risk level = 1 Not every hit is necessarily a security vulnerability. There may be other security vulnerabilities; review your code! See 'Secure Programming HOWTO' (https://dwheeler.com/secure-programs) for more information.