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/kpatch-0.6.0/kmod/core/kpatch.h
Examining data/kpatch-0.6.0/kmod/core/shadow.c
Examining data/kpatch-0.6.0/kmod/core/core.c
Examining data/kpatch-0.6.0/kmod/patch/kpatch-macros.h
Examining data/kpatch-0.6.0/kmod/patch/kpatch-patch-hook.c
Examining data/kpatch-0.6.0/kmod/patch/kpatch-patch.h
Examining data/kpatch-0.6.0/kmod/patch/livepatch-patch-hook.c
Examining data/kpatch-0.6.0/kmod/patch/patch-hook.c
Examining data/kpatch-0.6.0/kpatch-build/create-klp-module.c
Examining data/kpatch-0.6.0/kpatch-build/create-kpatch-module.c
Examining data/kpatch-0.6.0/kpatch-build/gcc-plugins/gcc-common.h
Examining data/kpatch-0.6.0/kpatch-build/gcc-plugins/gcc-generate-rtl-pass.h
Examining data/kpatch-0.6.0/kpatch-build/gcc-plugins/ppc64le-plugin.c
Examining data/kpatch-0.6.0/kpatch-build/insn/asm/inat.h
Examining data/kpatch-0.6.0/kpatch-build/insn/asm/inat_types.h
Examining data/kpatch-0.6.0/kpatch-build/insn/asm/insn.h
Examining data/kpatch-0.6.0/kpatch-build/insn/inat-tables.c
Examining data/kpatch-0.6.0/kpatch-build/insn/inat.c
Examining data/kpatch-0.6.0/kpatch-build/insn/insn.c
Examining data/kpatch-0.6.0/kpatch-build/kpatch-elf.c
Examining data/kpatch-0.6.0/kpatch-build/kpatch-elf.h
Examining data/kpatch-0.6.0/kpatch-build/kpatch-intermediate.h
Examining data/kpatch-0.6.0/kpatch-build/list.h
Examining data/kpatch-0.6.0/kpatch-build/log.h
Examining data/kpatch-0.6.0/kpatch-build/lookup.c
Examining data/kpatch-0.6.0/kpatch-build/lookup.h
Examining data/kpatch-0.6.0/kpatch-build/create-diff-object.c
Examining data/kpatch-0.6.0/test/testmod/testmod_drv.c

FINAL RESULTS:

data/kpatch-0.6.0/kpatch-build/create-diff-object.c:788:3:  [4] (buffer) sprintf:
  Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or
  vsnprintf.
		sprintf(name, ".rodata.%s", origname);
data/kpatch-0.6.0/kpatch-build/create-diff-object.c:792:3:  [4] (buffer) sprintf:
  Does not check for buffer overflows (CWE-120). Use sprintf_s, snprintf, or
  vsnprintf.
		sprintf(name, ".rodata.%s", basesym->name);
data/kpatch-0.6.0/kpatch-build/create-diff-object.c:2910:3:  [4] (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).
		strcpy(strtab, string->name);
data/kpatch-0.6.0/kpatch-build/create-klp-module.c:76:2:  [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(buf, 256, KLP_SYM_PREFIX "%s.%s,%s", objname, name, pos);
data/kpatch-0.6.0/kpatch-build/create-klp-module.c:114:2:  [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(buf, 256, KLP_RELASEC_PREFIX "%s.%s", objname, base->name);
data/kpatch-0.6.0/kpatch-build/gcc-plugins/ppc64le-plugin.c:49: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, PLUGIN_NAME ": can't find call instruction codes");
data/kpatch-0.6.0/kpatch-build/kpatch-elf.c:616:2:  [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(relaname, name);
data/kpatch-0.6.0/kpatch-build/log.h:19: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(format, ##__VA_ARGS__); \
data/kpatch-0.6.0/kpatch-build/lookup.c:285:9:  [4] (buffer) fscanf:
  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.
	while (fscanf(file, "%x %s %s %s\n",
data/kpatch-0.6.0/kpatch-build/lookup.c:297:9:  [4] (buffer) fscanf:
  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.
	while (fscanf(file, "%x %s %s %s\n",
data/kpatch-0.6.0/kpatch-build/create-diff-object.c:1596: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.
		str = getenv("BUG_STRUCT_SIZE");
data/kpatch-0.6.0/kpatch-build/create-diff-object.c:1611: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.
		str = getenv("EX_STRUCT_SIZE");
data/kpatch-0.6.0/kpatch-build/create-diff-object.c:1627: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.
		str = getenv("PARA_STRUCT_SIZE");
data/kpatch-0.6.0/kpatch-build/create-diff-object.c:1642: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.
		str = getenv("ALT_STRUCT_SIZE");
data/kpatch-0.6.0/kpatch-build/create-diff-object.c:1663: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.
		str = getenv("FIXUP_STRUCT_SIZE");
data/kpatch-0.6.0/kmod/patch/kpatch-patch-hook.c:47:9:  [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.
	return sprintf(buf, "%d\n", kpmod.enabled);
data/kpatch-0.6.0/kmod/patch/kpatch-patch-hook.c:107:9:  [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.
	return sprintf(buf, "0x%lx\n", func->old_addr);
data/kpatch-0.6.0/kmod/patch/kpatch-patch-hook.c:116:9:  [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.
	return sprintf(buf, "0x%lx\n", func->new_addr);
data/kpatch-0.6.0/kpatch-build/create-diff-object.c:745: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 name[256], *origname;
data/kpatch-0.6.0/kpatch-build/create-diff-object.c:1599:10:  [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).
		size = atoi(str);
data/kpatch-0.6.0/kpatch-build/create-diff-object.c:1614:10:  [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).
		size = atoi(str);
data/kpatch-0.6.0/kpatch-build/create-diff-object.c:1630:10:  [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).
		size = atoi(str);
data/kpatch-0.6.0/kpatch-build/create-diff-object.c:1645:10:  [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).
		size = atoi(str);
data/kpatch-0.6.0/kpatch-build/create-diff-object.c:1666:10:  [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).
		size = atoi(str);
data/kpatch-0.6.0/kpatch-build/create-diff-object.c:1896:3:  [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 + dest_offset, src + src_offset, group_size);
data/kpatch-0.6.0/kpatch-build/create-diff-object.c:2809:3:  [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(newdata, sym->sec->data->d_buf, sym->sec->data->d_size);
data/kpatch-0.6.0/kpatch-build/create-diff-object.c:2916: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 *args[6];
data/kpatch-0.6.0/kpatch-build/create-klp-module.c:47: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 pos[32], buf[256];
data/kpatch-0.6.0/kpatch-build/create-klp-module.c:111: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[256];
data/kpatch-0.6.0/kpatch-build/create-klp-module.c:237: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[256];
data/kpatch-0.6.0/kpatch-build/create-klp-module.c:299:3:  [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(sec->data->d_buf + old_size,
data/kpatch-0.6.0/kpatch-build/create-klp-module.c:349: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 *args[2];
data/kpatch-0.6.0/kpatch-build/create-kpatch-module.c:144: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 *args[2];
data/kpatch-0.6.0/kpatch-build/kpatch-elf.c:351: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(name, O_RDONLY);
data/kpatch-0.6.0/kpatch-build/kpatch-elf.c:491:3:  [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 + offset, sec->name, len);
data/kpatch-0.6.0/kpatch-build/kpatch-elf.c:544:3:  [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 + offset, sym->name, len);
data/kpatch-0.6.0/kpatch-build/kpatch-elf.c:590:3:  [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 + offset, &sym->sym, symtab->sh.sh_entsize);
data/kpatch-0.6.0/kpatch-build/kpatch-elf.c:615:2:  [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(relaname, ".rela");
data/kpatch-0.6.0/kpatch-build/lookup.c:189: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(path, O_RDONLY, 0)) < 0)
data/kpatch-0.6.0/kpatch-build/lookup.c:279: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 name[256], mod[256], export[256];
data/kpatch-0.6.0/kpatch-build/lookup.c:282: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).
	if ((file = fopen(path, "r")) < 0)
data/kpatch-0.6.0/test/testmod/testmod_drv.c:14:9:  [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.
	return sprintf(buf, "%d\n", value);
data/kpatch-0.6.0/kpatch-build/create-diff-object.c:223:36:  [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(sym->name, *prefix, strlen(*prefix)))
data/kpatch-0.6.0/kpatch-build/create-diff-object.c:1460: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).
		            strlen("__kpatch_force_func_")))
data/kpatch-0.6.0/kpatch-build/create-diff-object.c:2045: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).
		            strlen("__UNIQUE_ID_kpatch_ignore_section_")))
data/kpatch-0.6.0/kpatch-build/create-diff-object.c:2078: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).
		            strlen("__kpatch_ignore_func_")))
data/kpatch-0.6.0/kpatch-build/create-diff-object.c:2899: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).
		size += strlen(string->name) + 1;
data/kpatch-0.6.0/kpatch-build/create-diff-object.c:2911: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).
		strtab += strlen(string->name) + 1;
data/kpatch-0.6.0/kpatch-build/gcc-plugins/gcc-common.h:578:42:  [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).
		DECL_SECTION_NAME(node) = build_string(strlen(value) + 1, value);
data/kpatch-0.6.0/kpatch-build/kpatch-elf.c:145:12:  [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).
		index += strlen(string->name) + 1;
data/kpatch-0.6.0/kpatch-build/kpatch-elf.c:435:10:  [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).
	return !strlen(sym->name);
data/kpatch-0.6.0/kpatch-build/kpatch-elf.c:478: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).
		size += strlen(sec->name) + 1; /* include NULL terminator */
data/kpatch-0.6.0/kpatch-build/kpatch-elf.c:489: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).
		len = strlen(sec->name) + 1;
data/kpatch-0.6.0/kpatch-build/kpatch-elf.c:527: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).
		size += strlen(sym->name) + 1; /* include NULL terminator */
data/kpatch-0.6.0/kpatch-build/kpatch-elf.c:542: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).
		len = strlen(sym->name) + 1;
data/kpatch-0.6.0/kpatch-build/kpatch-elf.c:612: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).
	relaname = malloc(strlen(name) + strlen(".rela") + 1);
data/kpatch-0.6.0/kpatch-build/kpatch-elf.c:612: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).
	relaname = malloc(strlen(name) + strlen(".rela") + 1);

ANALYSIS SUMMARY:

Hits = 57
Lines analyzed = 11891 in approximately 1.42 seconds (8348 lines/second)
Physical Source Lines of Code (SLOC) = 8393
Hits@level = [0]  31 [1]  15 [2]  27 [3]   5 [4]  10 [5]   0
Hits@level+ = [0+]  88 [1+]  57 [2+]  42 [3+]  15 [4+]  10 [5+]   0
Hits/KSLOC@level+ = [0+] 10.4849 [1+] 6.79137 [2+] 5.00417 [3+] 1.7872 [4+] 1.19147 [5+]   0
Symlinks skipped = 1 (--allowlink overrides but see doc for security issue)
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.