Here is some that I found simple to make:
Author: mingodad <
address@hidden> 2013-01-31 01:17:50
Committer: mingodad <
address@hidden> 2013-01-31 01:17:50
Parent: 1b1e7ee1fd2f269872128dc5e8b830bd55dfa80c (Fix cross-compilation out-of-tree build)
Branch: vio_patch
Follows: release_0_9_25
Precedes:
Alerts found using Coverity Scan
----------------------------------- libtcc.c -----------------------------------
index b0a9b1a..69d9e0d 100644
@@ -479,8 +479,7 @@ ST_FUNC void put_extern_sym2(Sym *sym, Section *section,
case TOK_strlen:
case TOK_strcpy:
case TOK_alloca:
- strcpy(buf, "__bound_");
- strcat(buf, name);
+ snprintf(buf, sizeof(buf), "__bound_%s", name);
name = buf;
break;
}
----------------------------------- tccelf.c -----------------------------------
index a4dee19..479b2fa 100644
@@ -114,7 +114,7 @@ ST_FUNC int put_elf_sym(Section *s, uplong value, unsigned long size,
if (ELFW(ST_BIND)(info) != STB_LOCAL) {
/* add another hashing entry */
nbuckets = base[0];
- h = elf_hash(name) % nbuckets;
+ h = name ? elf_hash(name) % nbuckets : 0;
*ptr = base[2 + h];
base[2 + h] = sym_index;
base[1]++;
@@ -3052,7 +3052,7 @@ static int ld_add_file_list(TCCState *s1, const char *cmd, int as_needed)
ret = -1;
goto lib_parse_error;
}
- strcpy(libname, &filename[1]);
+ snprintf(libname, sizeof(libname), "%s", &filename[1]);
libname_to_filename(s1, libname, filename);
} else if (t != LD_TOK_NAME) {
tcc_error_noabort("filename expected");
----------------------------------- tccgen.c -----------------------------------
index 4300403..e06a932 100644
@@ -361,6 +361,7 @@ void vpush64(int ty, unsigned long long v)
CValue cval;
CType ctype;
ctype.t = ty;
+ ctype.ref = 0;
cval.ull = v;
vsetc(&ctype, VT_CONST, &cval);
}
@@ -1734,6 +1735,7 @@ ST_FUNC void gen_op(int op)
}
vswap();
type1.t = t;
+ type1.ref = 0;
gen_cast(&type1);
vswap();
/* special case for shifts and long long: we keep the shift as
@@ -2717,6 +2719,7 @@ static void struct_decl(CType *type, int u)
v = anon_sym++;
}
type1.t = a;
+ type1.ref = 0;
/* we put an undefined size for struct/union */
s = sym_push(v | SYM_STRUCT, &type1, 0, -1);
s->r = 0; /* default alignment is zero as gcc */
@@ -3396,6 +3399,7 @@ static void gfunc_param_typed(Sym *func, Sym *arg)
/* default casting : only need to convert float to double */
if ((vtop->type.t & VT_BTYPE) == VT_FLOAT) {
type.t = VT_DOUBLE;
+ type.ref = 0;
gen_cast(&type);
}
} else if (arg == NULL) {
@@ -3592,6 +3596,7 @@ ST_FUNC void unary(void)
if ((vtop->r & (VT_VALMASK | VT_LVAL | VT_SYM)) == VT_CONST) {
CType boolean;
boolean.t = VT_BOOL;
+ boolean.ref = 0;
gen_cast(&boolean);
vtop->c.i = !vtop->c.i;
} else if ((vtop->r & VT_VALMASK) == VT_CMP)
@@ -4101,6 +4106,7 @@ static void expr_cond(void)
CType boolean;
int c;
boolean.t = VT_BOOL;
+ boolean.ref = 0;
vdup();
gen_cast(&boolean);
c = vtop->c.i;
@@ -5574,7 +5580,7 @@ ST_FUNC void gen_inline_functions(void)
str = fn->token_str;
fn->sym = NULL;
if (file)
- strcpy(file->filename, fn->filename);
+ snprintf(file->filename, sizeof(file->filename), "%s", fn->filename);
sym->r = VT_SYM | VT_CONST;
sym->type.t &= ~VT_INLINE;