Code Review
/
src
/
app-framework-main.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
review
|
tree
raw
|
inline
| side by side
Fix a possible access to uninitialized memory
[src/app-framework-main.git]
/
src
/
wgtpkg-files.c
diff --git
a/src/wgtpkg-files.c
b/src/wgtpkg-files.c
index
cbd6048
..
cce6a04
100644
(file)
--- a/
src/wgtpkg-files.c
+++ b/
src/wgtpkg-files.c
@@
-1,5
+1,5
@@
/*
/*
- Copyright 2015 IoT.bzh
+ Copyright 2015
, 2016, 2017
IoT.bzh
author: José Bollo <jose.bollo@iot.bzh>
author: José Bollo <jose.bollo@iot.bzh>
@@
-50,7
+50,7
@@
static unsigned int what_signature(const char *name)
return UINT_MAX;
len = sizeof(distributor_file_prefix)-1;
return UINT_MAX;
len = sizeof(distributor_file_prefix)-1;
- if (
mem
cmp(name, distributor_file_prefix, len))
+ if (
strn
cmp(name, distributor_file_prefix, len))
return 0;
if (name[len] <= '0' || name[len] > '9')
return 0;
return 0;
if (name[len] <= '0' || name[len] > '9')
return 0;
@@
-252,9
+252,10
@@
void file_clear_flags()
allfiles.files[i]->flags &= flag_signature;
}
allfiles.files[i]->flags &= flag_signature;
}
-static int fill_files_rec(char name[PATH_MAX],
int
offset)
+static int fill_files_rec(char name[PATH_MAX],
unsigned
offset)
{
{
- int len, err, fd;
+ int err, fd;
+ unsigned len;
DIR *dir;
struct dirent *ent;
DIR *dir;
struct dirent *ent;
@@
-274,7
+275,7
@@
static int fill_files_rec(char name[PATH_MAX], int offset)
ent = readdir(dir);
while (ent != NULL) {
ent = readdir(dir);
while (ent != NULL) {
- len = strlen(ent->d_name);
+ len =
(unsigned)
strlen(ent->d_name);
if (ent->d_name[0] == '.' && (len == 1 ||
(ent->d_name[1] == '.' && len == 2)))
;
if (ent->d_name[0] == '.' && (len == 1 ||
(ent->d_name[1] == '.' && len == 2)))
;