The following issues were found
notes-utils.c
2 issues
Line: 127
Column: 33
CWE codes:
807
20
Suggestion:
Check environment variables carefully before using them
struct notes_rewrite_cfg *init_copy_notes_for_rewrite(const char *cmd)
{
struct notes_rewrite_cfg *c = xmalloc(sizeof(struct notes_rewrite_cfg));
const char *rewrite_mode_env = getenv(GIT_NOTES_REWRITE_MODE_ENVIRONMENT);
const char *rewrite_refs_env = getenv(GIT_NOTES_REWRITE_REF_ENVIRONMENT);
c->cmd = cmd;
c->enabled = 1;
c->combine = combine_notes_concatenate;
CALLOC_ARRAY(c->refs, 1);
Reported by FlawFinder.
Line: 128
Column: 33
CWE codes:
807
20
Suggestion:
Check environment variables carefully before using them
{
struct notes_rewrite_cfg *c = xmalloc(sizeof(struct notes_rewrite_cfg));
const char *rewrite_mode_env = getenv(GIT_NOTES_REWRITE_MODE_ENVIRONMENT);
const char *rewrite_refs_env = getenv(GIT_NOTES_REWRITE_REF_ENVIRONMENT);
c->cmd = cmd;
c->enabled = 1;
c->combine = combine_notes_concatenate;
CALLOC_ARRAY(c->refs, 1);
c->refs->strdup_strings = 1;
Reported by FlawFinder.
color.h
2 issues
Line: 118
Column: 24
CWE codes:
134
Suggestion:
Use a constant for the format specification
* the color. The `color_print_strbuf` prints the contents of the given
* strbuf (BUG: but only up to its first NUL character).
*/
__attribute__((format (printf, 3, 4)))
int color_fprintf(FILE *fp, const char *color, const char *fmt, ...);
__attribute__((format (printf, 3, 4)))
int color_fprintf_ln(FILE *fp, const char *color, const char *fmt, ...);
void color_print_strbuf(FILE *fp, const char *color, const struct strbuf *sb);
Reported by FlawFinder.
Line: 120
Column: 24
CWE codes:
134
Suggestion:
Use a constant for the format specification
*/
__attribute__((format (printf, 3, 4)))
int color_fprintf(FILE *fp, const char *color, const char *fmt, ...);
__attribute__((format (printf, 3, 4)))
int color_fprintf_ln(FILE *fp, const char *color, const char *fmt, ...);
void color_print_strbuf(FILE *fp, const char *color, const struct strbuf *sb);
/*
* Check if the given color is GIT_COLOR_NIL that means "no color selected".
Reported by FlawFinder.
dir.h
2 issues
Line: 44
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
struct dir_entry {
unsigned int len;
char name[FLEX_ARRAY]; /* more */
};
#define PATTERN_FLAG_NODIR 1
#define PATTERN_FLAG_ENDSWITH 4
#define PATTERN_FLAG_MUSTBEDIR 8
Reported by FlawFinder.
Line: 184
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
unsigned int recurse : 1;
/* null object ID means this directory does not have .gitignore */
struct object_id exclude_oid;
char name[FLEX_ARRAY];
};
struct untracked_cache {
struct oid_stat ss_info_exclude;
struct oid_stat ss_excludes_file;
Reported by FlawFinder.
builtin/remote-ext.c
2 issues
Line: 168
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
static int command_loop(const char *child)
{
char buffer[MAXCOMMAND];
while (1) {
size_t i;
if (!fgets(buffer, MAXCOMMAND - 1, stdin)) {
if (ferror(stdin))
Reported by FlawFinder.
Line: 178
Column: 7
CWE codes:
126
exit(0);
}
/* Strip end of line characters. */
i = strlen(buffer);
while (i > 0 && isspace(buffer[i - 1]))
buffer[--i] = 0;
if (!strcmp(buffer, "capabilities")) {
printf("*connect\n\n");
Reported by FlawFinder.
server-info.c
2 issues
Line: 30
Column: 24
CWE codes:
134
Suggestion:
Use a constant for the format specification
return uic->old_fp == NULL;
}
__attribute__((format (printf, 2, 3)))
static int uic_printf(struct update_info_ctx *uic, const char *fmt, ...)
{
va_list ap;
int ret = -1;
Reported by FlawFinder.
Line: 39
Column: 9
CWE codes:
134
Suggestion:
Use a constant for the format specification
va_start(ap, fmt);
if (uic_is_stale(uic)) {
ret = vfprintf(uic->cur_fp, fmt, ap);
} else {
ssize_t r;
struct strbuf *cur = &uic->cur_sb;
struct strbuf *old = &uic->old_sb;
Reported by FlawFinder.
builtin/mktree.c
2 issues
Line: 16
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
unsigned mode;
struct object_id oid;
int len;
char name[FLEX_ARRAY];
} **entries;
static int alloc, used;
static void append_to_tree(unsigned mode, struct object_id *oid, char *path)
{
Reported by FlawFinder.
Line: 23
Column: 15
CWE codes:
126
static void append_to_tree(unsigned mode, struct object_id *oid, char *path)
{
struct treeent *ent;
size_t len = strlen(path);
if (strchr(path, '/'))
die("path %s contains slash", path);
FLEX_ALLOC_MEM(ent, name, path, len);
ent->mode = mode;
Reported by FlawFinder.
sh-i18n--envsubst.c
2 issues
Line: 398
Column: 29
CWE codes:
807
20
Suggestion:
Check environment variables carefully before using them
if (valid)
{
/* Substitute the variable's value from the environment. */
const char *env_value = getenv (buffer);
if (env_value != NULL)
fputs (env_value, stdout);
}
else
Reported by FlawFinder.
object-store.h
2 issues
Line: 92
Column: 11
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
do_not_close:1,
pack_promisor:1,
multi_pack_index:1;
unsigned char hash[GIT_MAX_RAWSZ];
struct revindex_entry *revindex;
const uint32_t *revindex_data;
const uint32_t *revindex_map;
size_t revindex_size;
/* something like ".git/objects/pack/xxxxx.pack" */
Reported by FlawFinder.
Line: 98
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
const uint32_t *revindex_map;
size_t revindex_size;
/* something like ".git/objects/pack/xxxxx.pack" */
char pack_name[FLEX_ARRAY]; /* more */
};
struct multi_pack_index;
static inline int pack_map_entry_cmp(const void *unused_cmp_data,
Reported by FlawFinder.
object.c
2 issues
Line: 341
Column: 8
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
* A zero-length string to which object_array_entry::name can be
* initialized without requiring a malloc/free.
*/
static char object_array_slopbuf[1];
void add_object_array_with_path(struct object *obj, const char *name,
struct object_array *array,
unsigned mode, const char *path)
{
Reported by FlawFinder.
Line: 43
Column: 9
CWE codes:
126
int i;
if (len < 0)
len = strlen(str);
for (i = 1; i < ARRAY_SIZE(object_type_strings); i++)
if (!strncmp(str, object_type_strings[i], len) &&
object_type_strings[i][len] == '\0')
return i;
Reported by FlawFinder.
sha1dc/ubc_check.c
2 issues
Line: 31
#include <stdint.h>
#endif
#ifdef SHA1DC_CUSTOM_INCLUDE_UBC_CHECK_C
#include SHA1DC_CUSTOM_INCLUDE_UBC_CHECK_C
#endif
#include "ubc_check.h"
static const uint32_t DV_I_43_0_bit = (uint32_t)(1) << 0;
static const uint32_t DV_I_44_0_bit = (uint32_t)(1) << 1;
Reported by Cppcheck.
Line: 371
}
#ifdef SHA1DC_CUSTOM_TRAILING_INCLUDE_UBC_CHECK_C
#include SHA1DC_CUSTOM_TRAILING_INCLUDE_UBC_CHECK_C
#endif
Reported by Cppcheck.