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/vzquota-3.1/src/quotacheck.c Examining data/vzquota-3.1/src/vzdqload.c Examining data/vzquota-3.1/src/quota_io.c Examining data/vzquota-3.1/src/syscall.c Examining data/vzquota-3.1/src/common.c Examining data/vzquota-3.1/src/vzdqdump.c Examining data/vzquota-3.1/src/vzdqcheck.c Examining data/vzquota-3.1/src/quotaon.c Examining data/vzquota-3.1/src/main.c Examining data/vzquota-3.1/src/stat.c Examining data/vzquota-3.1/include/linux/vzctl_quota.h Examining data/vzquota-3.1/include/linux/quota.h Examining data/vzquota-3.1/include/linux/vzquota.h Examining data/vzquota-3.1/include/quota_io.h Examining data/vzquota-3.1/include/quotadump.h Examining data/vzquota-3.1/include/vzquota.h Examining data/vzquota-3.1/include/quotacheck.h Examining data/vzquota-3.1/include/kcompat.h Examining data/vzquota-3.1/include/common.h FINAL RESULTS: data/vzquota-3.1/src/common.c:81:2: [4] (format) fprintf: If format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant for the format specification. fprintf(output, VZQUOTA_LOG_PREFIX); data/vzquota-3.1/src/common.c:93:2: [4] (format) vfprintf: If format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant for the format specification. vfprintf(output, oformat, pvar); data/vzquota-3.1/src/common.c:412:2: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(newpath, "%s/%s", cwd, path); data/vzquota-3.1/src/common.c:629:3: [4] (format) fprintf: If format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant for the format specification. fprintf(stderr, usg, program_name); data/vzquota-3.1/src/common.c:631:3: [4] (format) fprintf: If format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant for the format specification. fprintf(stderr, usg, program_name, command_name); data/vzquota-3.1/src/quota_io.c:1089:2: [4] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. sprintf(path, "%s/root", root_path); data/vzquota-3.1/src/stat.c:199:5: [4] (buffer) strcat: Does not check for buffer overflows when concatenating to destination [MS-banned] (CWE-120). Consider using strcat_s, strncat, strlcat, or snprintf (warning: strncat is easily misused). strcat(status, strlen(status) ? ",dirty" : "dirty"); data/vzquota-3.1/src/vzdqdump.c:176:3: [4] (format) printf: If format strings can be influenced by an attacker, they can be exploited (CWE-134). Use a constant for the format specification. printf(FIRST_LEVEL_LABEL "\n"); data/vzquota-3.1/src/vzdqload.c:80:6: [4] (buffer) vsscanf: The scanf() family's %s operation, without a limit specification, permits buffer overflows (CWE-120, CWE-20). Specify a limit to %s, or use a different input function. If the scanf format is influenceable by an attacker, it's exploitable. i = vsscanf(line, fmt, pvar); data/vzquota-3.1/src/common.c:443:3: [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. getopt_long(argc, argv, short_options, long_options, data/vzquota-3.1/src/common.c:593:3: [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. getopt_long(*argc, *argv, short_options, long_options, data/vzquota-3.1/src/quota_io.c:1093:13: [3] (misc) chroot: chroot can be very helpful, but is hard to use correctly (CWE-250, CWE-22). Make sure the program immediately chdir("/"), closes file descriptors, and drops root privileges, and that all necessary files (and no more!) are in the new root. if ((err = chroot(path)) != 0) data/vzquota-3.1/src/quota_io.c:1098:8: [3] (misc) chroot: chroot can be very helpful, but is hard to use correctly (CWE-250, CWE-22). Make sure the program immediately chdir("/"), closes file descriptors, and drops root privileges, and that all necessary files (and no more!) are in the new root. err = chroot("."); data/vzquota-3.1/include/vzquota.h:78: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. extern char dev[QMAXDEVLEN]; data/vzquota-3.1/src/common.c:269: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 c, buf[ASP_STR_LEN], *p, *q; data/vzquota-3.1/src/common.c:362:4: [2] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. Risk is low because the source has a constant maximum length. sprintf(buf, "%ddays", days); data/vzquota-3.1/src/common.c:364:4: [2] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. Risk is low because the source has a constant maximum length. sprintf(buf, "%02d:%02d", hours, minutes); data/vzquota-3.1/src/common.c:367:4: [2] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. Risk is low because the source has a constant maximum length. sprintf(buf, "%uminutes", data/vzquota-3.1/src/common.c:370:4: [2] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. Risk is low because the source has a constant maximum length. sprintf(buf, "%uhours", hours + days * 24); data/vzquota-3.1/src/common.c:372:4: [2] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. Risk is low because the source has a constant maximum length. sprintf(buf, "%udays", days); data/vzquota-3.1/src/common.c:385:3: [2] (buffer) strcpy: Does not check for buffer overflows when copying to destination [MS-banned] (CWE-120). Consider using snprintf, strcpy_s, or strlcpy (warning: strncpy easily misused). Risk is low because the source is a constant string. strcpy(buf, "none"); data/vzquota-3.1/src/quota_io.c:48: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 quotanames[MAXQUOTAS + 1][20] = QUOTANAMES; data/vzquota-3.1/src/quota_io.c:105:2: [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(&(lptr->obj), obj, sizeof(struct ugid_obj)); data/vzquota-3.1/src/quota_io.c:396: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( dest, src, sizeof(struct vz_quota_stat_old1)); data/vzquota-3.1/src/quota_io.c:444: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( dest, src, sizeof(struct vz_quota_stat_old2)); data/vzquota-3.1/src/quota_io.c:491: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( dest, src, sizeof(struct vz_quota_stat)); data/vzquota-3.1/src/quota_io.c:614: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( &buf[j-i], &(dq->obj.istat), sizeof(struct vz_quota_iface)); data/vzquota-3.1/src/quota_io.c:845: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( &(dq->obj.istat), &buf[j], sizeof(struct vz_quota_iface)); data/vzquota-3.1/src/quota_io.c:974: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( &(dq->obj.istat), &buf[j], sizeof(struct vz_quota_iface)); data/vzquota-3.1/src/quota_io.c:1084: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 path[PATH_MAX]; data/vzquota-3.1/src/quota_io.c:1090:7: [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("/", O_RDONLY); data/vzquota-3.1/src/quota_io.c:1328: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 buf[MAXFILENAMELEN]; data/vzquota-3.1/src/quota_io.c:1445: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 buf[MAXFILENAMELEN]; data/vzquota-3.1/src/quota_io.c:1453:12: [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). if ((fd = open(name, flags, 00600)) < 0) data/vzquota-3.1/src/quota_io.c:1603:8: [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( &(dq->obj), &buf[j], sizeof(struct ugid_obj)); data/vzquota-3.1/src/quota_io.c:1727: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( &buf[i], &(dq->obj), sizeof(struct ugid_obj)); data/vzquota-3.1/src/quotacheck.c:75:7: [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(fname, O_RDONLY); data/vzquota-3.1/src/quotacheck.c:203:13: [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). if ((cwd = open(".", O_RDONLY)) == -1) data/vzquota-3.1/src/quotaon.c:471:2: [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(&old_conf, &(qd.ugid_stat.info.config), sizeof(struct vz_quota_ugid_stat)); data/vzquota-3.1/src/stat.c:78: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 buf[QMAXTIMELEN]; data/vzquota-3.1/src/stat.c:117: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 buf1[QMAXTIMELEN], buf2[QMAXTIMELEN]; data/vzquota-3.1/src/stat.c:186: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 status[256] = ""; data/vzquota-3.1/src/stat.c:193:4: [2] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. Risk is low because the source has a constant maximum length. sprintf(status, "%d %d", (dq->obj.flags & UGID_LOADED) ? 1 : 0, data/vzquota-3.1/src/stat.c:197:5: [2] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. Risk is low because the source has a constant maximum length. sprintf(status, "loaded"); data/vzquota-3.1/src/stat.c:205:4: [2] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. Risk is low because the source has a constant maximum length. sprintf(buf1, "%ld", t); data/vzquota-3.1/src/stat.c:219:4: [2] (buffer) sprintf: Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or vsnprintf. Risk is low because the source has a constant maximum length. sprintf(buf1, "%ld", t); data/vzquota-3.1/src/syscall.c:52:7: [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(VZCTL_DEVICE, O_RDWR); data/vzquota-3.1/src/syscall.c:88:7: [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(VZCTL_DEVICE, O_RDWR); data/vzquota-3.1/src/vzdqload.c:100: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 line[bufsize]; data/vzquota-3.1/src/vzdqload.c:101: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 label[bufsize]; data/vzquota-3.1/src/common.c:210: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). if (0 == strlen(s)) data/vzquota-3.1/src/common.c:274:18: [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 (0 == (len = strlen(s))) data/vzquota-3.1/src/common.c:280:2: [1] (buffer) strncpy: Easily used incorrectly; doesn't always \0-terminate or check for invalid pointers [MS-banned] (CWE-120). strncpy(buf, s, ASP_STR_LEN); data/vzquota-3.1/src/common.c:289: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 (0 == strlen(p)) data/vzquota-3.1/src/common.c:303: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). if (0 == strlen(q)) data/vzquota-3.1/src/common.c:308: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). if (0 == strlen(p)) data/vzquota-3.1/src/common.c:411:20: [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). newpath = xmalloc(strlen(cwd) + strlen(path) + 2); data/vzquota-3.1/src/common.c:411:34: [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). newpath = xmalloc(strlen(cwd) + strlen(path) + 2); data/vzquota-3.1/src/quota_io.c:514: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(buf) > getpagesize() - 2) data/vzquota-3.1/src/quota_io.c:681:3: [1] (obsolete) usleep: This C routine is considered obsolete (as opposed to the shell command by the same name). The interaction of this function with SIGALRM and other timer functions such as sleep(), alarm(), setitimer(), and nanosleep() is unspecified (CWE-676). Use nanosleep(2) or setitimer(2) instead. usleep(sleeptime * 1000); data/vzquota-3.1/src/quota_io.c:715: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(buf) > getpagesize() - 2) data/vzquota-3.1/src/quota_io.c:768:3: [1] (obsolete) usleep: This C routine is considered obsolete (as opposed to the shell command by the same name). The interaction of this function with SIGALRM and other timer functions such as sleep(), alarm(), setitimer(), and nanosleep() is unspecified (CWE-676). Use nanosleep(2) or setitimer(2) instead. usleep(sleeptime * 1000); data/vzquota-3.1/src/quota_io.c:1067:43: [1] (obsolete) ulimit: This C routine is considered obsolete (as opposed to the shell command by the same name, which is NOT obsolete) (CWE-676). Use getrlimit(2), setrlimit(2), and sysconf(3) instead. static void dqstat2dqblk(struct dq_stat * ulimit, data/vzquota-3.1/src/quota_io.c:1670:27: [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). q->path_len = q->path ? strlen(q->path) : 0; data/vzquota-3.1/src/stat.c:199:20: [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). strcat(status, strlen(status) ? ",dirty" : "dirty"); data/vzquota-3.1/src/vzdqload.c:248:4: [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). strlen(FIRST_LEVEL_LABEL)) != 0) { ANALYSIS SUMMARY: Hits = 66 Lines analyzed = 6008 in approximately 0.17 seconds (35878 lines/second) Physical Source Lines of Code (SLOC) = 4161 Hits@level = [0] 55 [1] 16 [2] 37 [3] 4 [4] 9 [5] 0 Hits@level+ = [0+] 121 [1+] 66 [2+] 50 [3+] 13 [4+] 9 [5+] 0 Hits/KSLOC@level+ = [0+] 29.0795 [1+] 15.8616 [2+] 12.0163 [3+] 3.12425 [4+] 2.16294 [5+] 0 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.