Skip to content

Commit

Permalink
[core] fix a NULL pointer deref when using a user supplied driver
Browse files Browse the repository at this point in the history
* Closes #40
  • Loading branch information
pbatard committed Jan 14, 2015
1 parent ac33121 commit 4f925b4
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 23 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,2,4,674
PRODUCTVERSION 1,2,4,674
FILEVERSION 1,2,4,675
PRODUCTVERSION 1,2,4,675
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.2.4.674"
VALUE "FileVersion", "1.2.4.675"
VALUE "InternalName", "WDI-Simple"
VALUE "LegalCopyright", "� 2010-2014 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.2.4.674"
VALUE "ProductVersion", "1.2.4.675"
VALUE "Comments", "http://libwdi.akeo.ie"
END
END
Expand Down
8 changes: 4 additions & 4 deletions examples/zadic.rc
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,8 @@ END
//

VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,2,4,674
PRODUCTVERSION 1,2,4,674
FILEVERSION 1,2,4,675
PRODUCTVERSION 1,2,4,675
FILEFLAGSMASK 0x17L
#ifdef _DEBUG
FILEFLAGS 0x1L
Expand All @@ -74,13 +74,13 @@ BEGIN
BEGIN
VALUE "CompanyName", "akeo.ie"
VALUE "FileDescription", "Zadic"
VALUE "FileVersion", "1.2.4.674"
VALUE "FileVersion", "1.2.4.675"
VALUE "InternalName", "Zadic"
VALUE "LegalCopyright", "� 2010-2014 Pete Batard (LGPL v3)"
VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/lesser.html"
VALUE "OriginalFilename", "zadic.exe"
VALUE "ProductName", "Zadic"
VALUE "ProductVersion", "1.2.4.674"
VALUE "ProductVersion", "1.2.4.675"
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.1.1.674"
#define APP_VERSION "Zadig 2.1.1.675"

// 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 @@ -248,8 +248,8 @@ END
//

VS_VERSION_INFO VERSIONINFO
FILEVERSION 2,1,1,674
PRODUCTVERSION 2,1,1,674
FILEVERSION 2,1,1,675
PRODUCTVERSION 2,1,1,675
FILEFLAGSMASK 0x17L
#ifdef _DEBUG
FILEFLAGS 0x1L
Expand All @@ -266,13 +266,13 @@ BEGIN
BEGIN
VALUE "CompanyName", "akeo.ie"
VALUE "FileDescription", "Zadig"
VALUE "FileVersion", "2.1.1.674"
VALUE "FileVersion", "2.1.1.675"
VALUE "InternalName", "Zadig"
VALUE "LegalCopyright", "� 2010-2014 Pete Batard (GPL v3)"
VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/gpl.html"
VALUE "OriginalFilename", "zadig.exe"
VALUE "ProductName", "Zadig"
VALUE "ProductVersion", "2.1.1.674"
VALUE "ProductVersion", "2.1.1.675"
VALUE "Comments", "http://libwdi.akeo.ie"
END
END
Expand Down
14 changes: 8 additions & 6 deletions libwdi/libwdi.c
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ int get_version_info(int driver_type, VS_FIXEDFILEINFO* driver_info)
UINT junk;
VS_FIXEDFILEINFO *file_info;

if ((driver_type < 0) || (driver_type >= ARRAYSIZE(driver_version)) || (driver_info == NULL)) {
if ((driver_type < 0) || (driver_type >= WDI_USER) || (driver_info == NULL)) {
return WDI_ERROR_INVALID_PARAM;
}

Expand Down Expand Up @@ -459,10 +459,12 @@ int get_version_info(int driver_type, VS_FIXEDFILEINFO* driver_info)
// Find out if the driver selected is actually embedded in this version of the library
BOOL LIBWDI_API wdi_is_driver_supported(int driver_type, VS_FIXEDFILEINFO* driver_info)
{
if (driver_info != NULL) {
memset(driver_info, 0, sizeof(VS_FIXEDFILEINFO));
if (driver_type < WDI_USER) { // github issue #40
if (driver_info != NULL) {
memset(driver_info, 0, sizeof(VS_FIXEDFILEINFO));
}
get_version_info(driver_type, driver_info);
}
get_version_info(driver_type, driver_info);

switch (driver_type) {
case WDI_WINUSB:
Expand Down Expand Up @@ -1032,7 +1034,7 @@ int LIBWDI_API wdi_prepare_driver(struct wdi_device_info* device_info, const cha
}

// Ensure driver_type is what we expect
if ( (driver_type < 0) || (driver_type > 3) ) {
if ( (driver_type < 0) || (driver_type > WDI_USER) ) {
wdi_err("unknown type");
MUTEX_RETURN(WDI_ERROR_INVALID_PARAM);
}
Expand Down Expand Up @@ -1156,7 +1158,7 @@ int LIBWDI_API wdi_prepare_driver(struct wdi_device_info* device_info, const cha
static_sprintf(inf_entities[KMDF_VERSION].replace, "%d.%d", WDF_VER/1000, WDF_VER%1000);

// Extra check, in case somebody modifies our code
if ((driver_type < 0) && (driver_type > ARRAYSIZE(driver_version))) {
if ((driver_type < 0) && (driver_type >= WDI_USER)) {
wdi_err("program assertion failed - driver_version[] index out of range");
MUTEX_RETURN(WDI_ERROR_OTHER);
}
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,2,4,674
PRODUCTVERSION 1,2,4,674
FILEVERSION 1,2,4,675
PRODUCTVERSION 1,2,4,675
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.2.4.674"
VALUE "FileVersion", "1.2.4.675"
VALUE "InternalName", "libwdi"
VALUE "LegalCopyright", "� 2010-2014 Pete Batard (LGPL v3)"
VALUE "LegalTrademarks", "http://www.gnu.org/copyleft/lesser.html"
VALUE "OriginalFilename", "libwdi"
VALUE "ProductName", "libwdi"
VALUE "ProductVersion", "1.2.4.674"
VALUE "ProductVersion", "1.2.4.675"
VALUE "Comments", "http://libwdi.akeo.ie"
END
END
Expand Down

0 comments on commit 4f925b4

Please sign in to comment.