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/ros-rospack-2.6.2/include/rospack/macros.h Examining data/ros-rospack-2.6.2/include/rospack/rospack.h Examining data/ros-rospack-2.6.2/include/rospack/rospack_backcompat.h Examining data/ros-rospack-2.6.2/src/rospack_backcompat.cpp Examining data/ros-rospack-2.6.2/src/rospack_cmdline.cpp Examining data/ros-rospack-2.6.2/src/rospack_cmdline.h Examining data/ros-rospack-2.6.2/src/rospack_main.cpp Examining data/ros-rospack-2.6.2/src/rosstack_main.cpp Examining data/ros-rospack-2.6.2/src/utils.cpp Examining data/ros-rospack-2.6.2/src/utils.h Examining data/ros-rospack-2.6.2/src/rospack.cpp Examining data/ros-rospack-2.6.2/test/test/utest.cpp FINAL RESULTS: data/ros-rospack-2.6.2/src/rospack.cpp:46:11: [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. #define snprintf _snprintf data/ros-rospack-2.6.2/src/rospack.cpp:46:20: [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. #define snprintf _snprintf data/ros-rospack-2.6.2/src/rospack.cpp:48:11: [4] (shell) popen: 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. #define popen _popen data/ros-rospack-2.6.2/src/rospack.cpp:2065: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(tmp_cache_path, sizeof(tmp_cache_path), temp_name); data/ros-rospack-2.6.2/src/rospack.cpp:2252:12: [4] (shell) popen: 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. if(!(p = popen(cmd.c_str(), "r"))) data/ros-rospack-2.6.2/src/rospack.cpp:287:15: [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. char* rpp = getenv("ROS_PACKAGE_PATH"); data/ros-rospack-2.6.2/src/rospack.cpp:1951:20: [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. char* ros_home = getenv("ROS_HOME"); data/ros-rospack-2.6.2/src/rospack.cpp:1960:24: [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. char* home_drive = getenv("HOMEDRIVE"); data/ros-rospack-2.6.2/src/rospack.cpp:1961:23: [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. char* home_path = getenv("HOMEPATH"); data/ros-rospack-2.6.2/src/rospack.cpp:1971:19: [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. home_path = getenv("HOME"); data/ros-rospack-2.6.2/src/rospack.cpp:1998:15: [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. char* rpp = getenv("ROS_PACKAGE_PATH"); data/ros-rospack-2.6.2/src/rospack.cpp:2064:23: [3] (tmpfile) tempnam: Temporary file race condition (CWE-377). char* temp_name = tempnam(dirname(tmp_cache_dir),".rospack_cache."); data/ros-rospack-2.6.2/src/rospack.cpp:2115:21: [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. char *rpp = getenv("ROS_PACKAGE_PATH"); data/ros-rospack-2.6.2/src/rospack.cpp:2144:37: [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. const char *user_cache_time_str = getenv("ROS_CACHE_TIMEOUT"); data/ros-rospack-2.6.2/src/rospack.cpp:2174:34: [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. const char* ros_package_path = getenv("ROS_PACKAGE_PATH"); data/ros-rospack-2.6.2/src/rospack_cmdline.cpp:316:28: [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((ros_lang_disable = getenv("ROS_LANG_DISABLE"))) data/ros-rospack-2.6.2/test/test/utest.cpp:148:18: [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. char* oldrpp = getenv("ROS_PACKAGE_PATH"); data/ros-rospack-2.6.2/test/test/utest.cpp:329:18: [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. char* oldrpp = getenv("ROS_PACKAGE_PATH"); data/ros-rospack-2.6.2/test/test/utest.cpp:404:21: [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. char* oldpath = getenv("PATH"); data/ros-rospack-2.6.2/src/rospack.cpp:1358: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[16]; data/ros-rospack-2.6.2/src/rospack.cpp:1385:7: [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[16]; data/ros-rospack-2.6.2/src/rospack.cpp:2003: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[21]; data/ros-rospack-2.6.2/src/rospack.cpp:2017: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 linebuf[30000]; data/ros-rospack-2.6.2/src/rospack.cpp:2055: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 tmp_cache_path[PATH_MAX]; data/ros-rospack-2.6.2/src/rospack.cpp:2056: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 drive[_MAX_DRIVE], dir[_MAX_DIR], fname[_MAX_FNAME], ext[_MAX_EXT]; data/ros-rospack-2.6.2/src/rospack.cpp:2059: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_dir[_MAX_DRIVE + _MAX_DIR]; data/ros-rospack-2.6.2/src/rospack.cpp:2063: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 tmp_cache_path[PATH_MAX]; data/ros-rospack-2.6.2/src/rospack.cpp:2076:14: [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(tmp_cache_path, O_RDWR | O_EXCL | _O_CREAT, 0644); data/ros-rospack-2.6.2/src/rospack.cpp:2094:21: [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 *cache = fopen(tmp_cache_path, "w"); data/ros-rospack-2.6.2/src/rospack.cpp:2097:14: [2] (tmpfile) mkstemp: Potential for temporary file vulnerability in some circumstances. Some older Unix-like systems create temp files with permission to write by all by default, so be sure to set the umask to override this. Also, some older Unix systems might fail to use O_EXCL when opening the file, so make sure that O_EXCL is used by the library (CWE-377). int fd = mkstemp(tmp_cache_path); data/ros-rospack-2.6.2/src/rospack.cpp:2151:17: [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* cache = fopen(cache_path.c_str(), "r"); data/ros-rospack-2.6.2/src/rospack.cpp:2172: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 linebuf[30000]; data/ros-rospack-2.6.2/src/rospack.cpp:2263: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[8192]; data/ros-rospack-2.6.2/src/rospack_backcompat.cpp:76:5: [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(argv[i], it->c_str(), it->size()); data/ros-rospack-2.6.2/src/rospack_cmdline.cpp:116:14: [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). length = atoi(length_str.c_str()); data/ros-rospack-2.6.2/test/test/utest.cpp:152: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 buf[1024]; data/ros-rospack-2.6.2/test/test/utest.cpp:331: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 buf[1024]; data/ros-rospack-2.6.2/test/test/utest.cpp:395: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 buf[1024]; data/ros-rospack-2.6.2/src/rospack.cpp:2052:5: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(tmp_cache_dir, cache_path.c_str(), len); data/ros-rospack-2.6.2/src/rospack.cpp:2069: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(temp_dirname) + 22 + 1; data/ros-rospack-2.6.2/src/rospack.cpp:2096:19: [1] (access) umask: Ensure that umask is given most restrictive possible setting (e.g., 066 or 077) (CWE-732). mode_t mask = umask(S_IXUSR | S_IRWXG | S_IRWXO); data/ros-rospack-2.6.2/src/rospack.cpp:2098:5: [1] (access) umask: Ensure that umask is given most restrictive possible setting (e.g., 066 or 077) (CWE-732). umask(mask); data/ros-rospack-2.6.2/src/rospack.cpp:2179: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). linebuf[strlen(linebuf)-1] = 0; // get rid of trailing newline data/ros-rospack-2.6.2/src/rospack.cpp:2186:15: [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(linebuf+18)) data/ros-rospack-2.6.2/src/rospack.cpp:2269: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). while(fgets(buf + strlen(buf),sizeof(buf)-strlen(buf)-1,p)); data/ros-rospack-2.6.2/src/rospack.cpp:2269:49: [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). while(fgets(buf + strlen(buf),sizeof(buf)-strlen(buf)-1,p)); data/ros-rospack-2.6.2/src/rospack.cpp:2283: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). buf[strlen(buf)-1] = '\0'; ANALYSIS SUMMARY: Hits = 47 Lines analyzed = 4877 in approximately 0.15 seconds (32274 lines/second) Physical Source Lines of Code (SLOC) = 3617 Hits@level = [0] 19 [1] 9 [2] 19 [3] 14 [4] 5 [5] 0 Hits@level+ = [0+] 66 [1+] 47 [2+] 38 [3+] 19 [4+] 5 [5+] 0 Hits/KSLOC@level+ = [0+] 18.2472 [1+] 12.9942 [2+] 10.5059 [3+] 5.25297 [4+] 1.38236 [5+] 0 Dot directories skipped = 2 (--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.