Skip to content

Commit

Permalink
[misc] fix Coverity warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
pbatard committed Oct 29, 2021
1 parent 8a0c476 commit e56e653
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 34 deletions.
8 changes: 4 additions & 4 deletions examples/wdi-simple.rc
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
#endif

VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,4,762,0
PRODUCTVERSION 1,4,762,0
FILEVERSION 1,4,763,0
PRODUCTVERSION 1,4,763,0
FILEFLAGSMASK 0x17L
#ifdef _DEBUG
FILEFLAGS 0x1L
Expand All @@ -25,13 +25,13 @@ BEGIN
BEGIN
VALUE "CompanyName", "akeo.ie"
VALUE "FileDescription", "WDI-Simple"
VALUE "FileVersion", "1.3.762"
VALUE "FileVersion", "1.3.763"
VALUE "InternalName", "WDI-Simple"
VALUE "LegalCopyright", "� 2010-2018 Pete Batard (LGPL v3)"
VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/lesser.html"
VALUE "OriginalFilename", "wdi-simple.exe"
VALUE "ProductName", "WDI-Simple"
VALUE "ProductVersion", "1.3.762"
VALUE "ProductVersion", "1.3.763"
VALUE "Comments", "http://libwdi.akeo.ie"
END
END
Expand Down
2 changes: 1 addition & 1 deletion examples/zadig.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
#define FIELD_ORANGE RGB(255,240,200)
#define ARROW_GREEN RGB(92,228,65)
#define ARROW_ORANGE RGB(253,143,56)
#define APP_VERSION "Zadig 2.6.762"
#define APP_VERSION "Zadig 2.6.763"

// These are used to flag end users about the driver they are going to replace
enum driver_type {
Expand Down
8 changes: 4 additions & 4 deletions examples/zadig.rc
Original file line number Diff line number Diff line change
Expand Up @@ -246,8 +246,8 @@ END
//

VS_VERSION_INFO VERSIONINFO
FILEVERSION 2,6,762,0
PRODUCTVERSION 2,6,762,0
FILEVERSION 2,6,763,0
PRODUCTVERSION 2,6,763,0
FILEFLAGSMASK 0x17L
#ifdef _DEBUG
FILEFLAGS 0x1L
Expand All @@ -264,13 +264,13 @@ BEGIN
BEGIN
VALUE "CompanyName", "akeo.ie"
VALUE "FileDescription", "Zadig"
VALUE "FileVersion", "2.6.762"
VALUE "FileVersion", "2.6.763"
VALUE "InternalName", "Zadig"
VALUE "LegalCopyright", "� 2010-2018 Pete Batard (GPL v3)"
VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html"
VALUE "OriginalFilename", "zadig.exe"
VALUE "ProductName", "Zadig"
VALUE "ProductVersion", "2.6.762"
VALUE "ProductVersion", "2.6.763"
VALUE "Comments", "http://libwdi.akeo.ie"
END
END
Expand Down
43 changes: 22 additions & 21 deletions libwdi/libwdi.c
Original file line number Diff line number Diff line change
Expand Up @@ -1154,30 +1154,31 @@ static long wdi_tokenize_resource(const char* resource_name, char** dst, const t
static long wdi_tokenize_file(const char* src, char** dst, const token_entity_t* token_entities,
const char* tok_prefix, const char* tok_suffix, int recursive)
{
long ret = -ERROR_RESOURCE_DATA_NOT_FOUND;

FILE* fd = NULL;
long size, ret = -ERROR_RESOURCE_DATA_NOT_FOUND;
char* buffer = NULL;

fd = fopen(src, "r");
if (fd) {
fseek(fd, 0L, SEEK_END);
long size = ftell(fd);
fseek(fd, 0L, SEEK_SET);

buffer = (char*)malloc(size);
if (buffer == NULL) {
wdi_err("Could not allocate tokenization buffer");
ret = WDI_ERROR_RESOURCE;
goto out;
}
if (fread(buffer, 1, size, fd) < 0) {
wdi_err("Could not read file to tokenize");
ret = -ERROR_RESOURCE_DATA_NOT_FOUND;
goto out;
}
ret = tokenize_string(buffer, size, dst, token_entities, tok_prefix, tok_suffix, recursive);
if (fd == NULL)
goto out;
fseek(fd, 0L, SEEK_END);
size = ftell(fd);
if (size < 0)
goto out;
fseek(fd, 0L, SEEK_SET);
// +1 for NUL terminator since we pass the whole file as a text string
buffer = (char*)calloc(size + 1, 1);
if (buffer == NULL) {
wdi_err("Could not allocate tokenization buffer");
ret = WDI_ERROR_RESOURCE;
goto out;
}
if (fread(buffer, 1, size, fd) != size) {
wdi_err("Could not read file to tokenize");
ret = -ERROR_RESOURCE_DATA_NOT_FOUND;
goto out;
}
ret = tokenize_string(buffer, size, dst, token_entities, tok_prefix, tok_suffix, recursive);

out:
free(buffer);
Expand Down Expand Up @@ -1227,7 +1228,7 @@ int LIBWDI_API wdi_prepare_driver(struct wdi_device_info* device_info, const cha
}

// If we are dealing with a path (e.g. option 'external_inf'), remove the directory part
inf_name = filename(inf);
inf_name = (char*)filename(inf);

// Check the inf file provided and create the cat file name
if (strcmp(inf_name+safe_strlen(inf_name)-4, inf_ext) != 0) {
Expand Down Expand Up @@ -1419,7 +1420,7 @@ int LIBWDI_API wdi_prepare_driver(struct wdi_device_info* device_info, const cha
(int)driver_version[driver_type].dwFileVersionLS>>16, (int)driver_version[driver_type].dwFileVersionLS&0xFFFF);

// Tokenize the inf
if (options->external_inf)
if ((options != NULL) && (options->external_inf))
inf_file_size = wdi_tokenize_file(inf, &dst, inf_entities, "#", "#", 0);
else
inf_file_size = wdi_tokenize_resource(inf_template[driver_type], &dst, inf_entities, "#", "#", 0);
Expand Down
8 changes: 4 additions & 4 deletions libwdi/libwdi.rc
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ END
//

VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,4,762,0
PRODUCTVERSION 1,4,762,0
FILEVERSION 1,4,763,0
PRODUCTVERSION 1,4,763,0
FILEFLAGSMASK 0x17L
#ifdef _DEBUG
FILEFLAGS 0x1L
Expand All @@ -68,13 +68,13 @@ BEGIN
BEGIN
VALUE "CompanyName", "akeo.ie"
VALUE "FileDescription", "libwdi: Windows Driver Installer Library"
VALUE "FileVersion", "1.3.762"
VALUE "FileVersion", "1.3.763"
VALUE "InternalName", "libwdi"
VALUE "LegalCopyright", "� 2010-2017 Pete Batard (LGPL v3)"
VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/lesser.html"
VALUE "OriginalFilename", "libwdi"
VALUE "ProductName", "libwdi"
VALUE "ProductVersion", "1.3.762"
VALUE "ProductVersion", "1.3.763"
VALUE "Comments", "http://libwdi.akeo.ie"
END
END
Expand Down

0 comments on commit e56e653

Please sign in to comment.