The following issues were found

sha256/gcrypt.h
1 issues
memcpy - Does not check for buffer overflows when copying to destination
Security

Line: 22 Column: 2 CWE codes: 120
Suggestion: Make sure destination can always hold the source data

              
inline void gcrypt_SHA256_Final(unsigned char *digest, gcrypt_SHA256_CTX *ctx)
{
	memcpy(digest, gcry_md_read(*ctx, GCRY_MD_SHA256), SHA256_DIGEST_SIZE);
}

inline void gcrypt_SHA256_Clone(gcrypt_SHA256_CTX *dst, const gcrypt_SHA256_CTX *src)
{
	gcry_md_copy(dst, *src);

            

Reported by FlawFinder.

ws.c
1 issues
atoi - Unless checked, the resulting number can exceed the expected range
Security

Line: 56 Column: 24 CWE codes: 190
Suggestion: 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)

              			break;
		}
		if (strncmp(string, "tabwidth=", 9) == 0) {
			unsigned tabwidth = atoi(string + 9);
			if (0 < tabwidth && tabwidth < 0100) {
				rule &= ~WS_TAB_WIDTH_MASK;
				rule |= tabwidth;
			}
			else

            

Reported by FlawFinder.

builtin/hash-object.c
1 issues
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?
Security

Line: 56 Column: 7 CWE codes: 362

              			unsigned flags, int literally)
{
	int fd;
	fd = open(path, O_RDONLY);
	if (fd < 0)
		die_errno("Cannot open '%s'", path);
	hash_fd(fd, type, vpath, flags, literally);
}


            

Reported by FlawFinder.

builtin/get-tar-commit-id.c
1 issues
char - Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues
Security

Line: 19 Column: 2 CWE codes: 119 120
Suggestion: Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length

              
int cmd_get_tar_commit_id(int argc, const char **argv, const char *prefix)
{
	char buffer[HEADERSIZE];
	struct ustar_header *header = (struct ustar_header *)buffer;
	char *content = buffer + RECORDSIZE;
	const char *comment;
	ssize_t n;
	long len;

            

Reported by FlawFinder.

strvec.c
1 issues
memcpy - Does not check for buffer overflows when copying to destination
Security

Line: 10 Column: 2 CWE codes: 120
Suggestion: Make sure destination can always hold the source data

              void strvec_init(struct strvec *array)
{
	struct strvec blank = STRVEC_INIT;
	memcpy(array, &blank, sizeof(*array));
}

static void strvec_push_nodup(struct strvec *array, const char *value)
{
	if (array->v == empty_strvec)

            

Reported by FlawFinder.

strvec.h
1 issues
printf - If format strings can be influenced by an attacker, they can be exploited
Security

Line: 51 Column: 24 CWE codes: 134
Suggestion: Use a constant for the format specification

               * Format a string and push it onto the end of the array. This is a
 * convenience wrapper combining `strbuf_addf` and `strvec_push`.
 */
__attribute__((format (printf,2,3)))
const char *strvec_pushf(struct strvec *, const char *fmt, ...);

/**
 * Push a list of strings onto the end of the array. The arguments
 * should be a list of `const char *` strings, terminated by a NULL

            

Reported by FlawFinder.

builtin/fmt-merge-msg.c
1 issues
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?
Security

Line: 44 Column: 8 CWE codes: 362

              		shortlog_len = (merge_log_config > 0) ? merge_log_config : 0;

	if (inpath && strcmp(inpath, "-")) {
		in = fopen(inpath, "r");
		if (!in)
			die_errno("cannot open '%s'", inpath);
	}

	if (strbuf_read(&input, fileno(in), 0) < 0)

            

Reported by FlawFinder.

t/helper/test-chmtime.c
1 issues
chmod - This accepts filename arguments; if an attacker can move those files, a race condition results.
Security

Line: 119 Column: 5 CWE codes: 362
Suggestion: Use fchmod( ) instead

              
#ifdef GIT_WINDOWS_NATIVE
		if (!(sb.st_mode & S_IWUSR) &&
				chmod(argv[i], sb.st_mode | S_IWUSR)) {
			fprintf(stderr, "Could not make user-writable %s: %s",
				argv[i], strerror(errno));
			return 1;
		}
#endif

            

Reported by FlawFinder.

t/helper/test-dump-cache-tree.c
1 issues
char - Statically-sized arrays can be improperly restricted, leading to potential overflows or other issues
Security

Line: 46 Column: 3 CWE codes: 119 120
Suggestion: Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length

              	}

	for (i = 0; i < it->subtree_nr; i++) {
		char path[PATH_MAX];
		struct cache_tree_sub *down = it->down[i];
		struct cache_tree_sub *rdwn;

		rdwn = cache_tree_sub(ref, down->name);
		xsnprintf(path, sizeof(path), "%s%.*s/", pfx, down->namelen, down->name);

            

Reported by FlawFinder.

t/helper/test-dump-fsmonitor.c
1 issues
printf - If format strings can be influenced by an attacker, they can be exploited
Security

Line: 19 Column: 3 CWE codes: 134
Suggestion: Use a constant for the format specification

              	printf("fsmonitor last update %s\n", istate->fsmonitor_last_update);

	for (i = 0; i < istate->cache_nr; i++)
		printf((istate->cache[i]->ce_flags & CE_FSMONITOR_VALID) ? "+" : "-");

	return 0;
}

            

Reported by FlawFinder.