[PATCH] rasapi32: Added error checks to RasEnumConnection,
RasEnumDevices, RasEnumEntries. 2nd try
John Smith
xixsimplicityxix at gmail.com
Mon Feb 12 15:30:20 CST 2007
Skipped content of type multipart/alternative-------------- next part --------------
From c6de5ffcb71c9262e22176eb3f48d919aa67de9b Mon Sep 17 00:00:00 2001
From: John Klehm <xixsimplicityxix at gmail.com>
Date: Mon, 12 Feb 2007 01:44:04 -0600
Subject: Added error checks to RasEnumConnections, RasEnumDevices,and RasEnumEntries
---
dlls/rasapi32/rasapi.c | 161 +++++++++++++++++++++++++++++++++++++++++------
1 files changed, 140 insertions(+), 21 deletions(-)
diff --git a/dlls/rasapi32/rasapi.c b/dlls/rasapi32/rasapi.c
index 0977ffe..d6ac242 100644
--- a/dlls/rasapi32/rasapi.c
+++ b/dlls/rasapi32/rasapi.c
@@ -98,27 +98,47 @@ DWORD WINAPI RasEditPhonebookEntryW(HWND hwnd, LPCWSTR lpszPhonebook, LPCWSTR lp
/**************************************************************************
* RasEnumConnectionsA [RASAPI32.544]
*/
-DWORD WINAPI RasEnumConnectionsA( LPRASCONNA rca, LPDWORD lpcb, LPDWORD lpcConnections) {
+DWORD WINAPI RasEnumConnectionsA( LPRASCONNA lprasconna, LPDWORD lpcb, LPDWORD lpcConnections)
+{
/* Remote Access Service stuff is done by underlying OS anyway */
- FIXME("(%p,%p,%p),stub!\n",rca,lpcb,lpcConnections);
+ FIXME("(%p,%p,%p),stub!\n",lprasconna,lpcb,lpcConnections);
FIXME("RAS support is not implemented! Configure program to use LAN connection/winsock instead!\n");
+
+ /* size of buffer from lpcb should be consistent with the version
+ * to be used in this function */
+ if (*lpcb < sizeof(RASCONNA))
+ {
+ *lpcb = sizeof(RASCONNA);
+ return ERROR_INVALID_SIZE;
+ }
+
*lpcb = 0; /* size of buffer needed to enumerate connections */
*lpcConnections = 0; /* no RAS connections available */
- return 0;
+ return 0; /* function executed correctly */
}
/**************************************************************************
* RasEnumConnectionsW [RASAPI32.545]
*/
-DWORD WINAPI RasEnumConnectionsW( LPRASCONNW rcw, LPDWORD lpcb, LPDWORD lpcConnections) {
+DWORD WINAPI RasEnumConnectionsW( LPRASCONNW lprasconnw, LPDWORD lpcb, LPDWORD lpcConnections)
+{
/* Remote Access Service stuff is done by underlying OS anyway */
- FIXME("(%p,%p,%p),stub!\n",rcw,lpcb,lpcConnections);
+ FIXME("(%p,%p,%p),stub!\n",lprasconnw,lpcb,lpcConnections);
FIXME("RAS support is not implemented! Configure program to use LAN connection/winsock instead!\n");
+
+ /* size of buffer from lpcb should be consistent with the version
+ * to be used in this function */
+ if (*lpcb < sizeof(RASCONNW))
+ {
+ *lpcb = sizeof(RASCONNW);
+ return ERROR_INVALID_SIZE;
+ }
+
*lpcb = 0; /* size of buffer needed to enumerate connections */
*lpcConnections = 0; /* no RAS connections available */
- return 0;
+ return 0; /* function executed correctly */
}
/**************************************************************************
@@ -130,8 +150,18 @@ DWORD WINAPI RasEnumEntriesA( LPCSTR Reserved, LPCSTR lpszPhoneBook,
{
FIXME("(%p,%s,%p,%p,%p),stub!\n",Reserved,debugstr_a(lpszPhoneBook),
lpRasEntryName,lpcb,lpcEntries);
+
+ /* size of buffer from lpcb should be consistent with the version
+ * to be used in this function */
+ if (*lpcb < sizeof(RASENTRYNAMEA))
+ {
+ return ERROR_INVALID_SIZE;
+ }
+
+ *lpcb = 0; /* size of bytes needed to complete the call */
*lpcEntries = 0;
- return 0;
+
+ return 0; /* function executed correctly */
}
/**************************************************************************
@@ -143,20 +173,48 @@ DWORD WINAPI RasEnumEntriesW( LPCWSTR Reserved, LPCWSTR lpszPhoneBook,
{
FIXME("(%p,%s,%p,%p,%p),stub!\n",Reserved,debugstr_w(lpszPhoneBook),
lpRasEntryName,lpcb,lpcEntries);
+
+ /* size of buffer from lpcb should be consistent with the version
+ * to be used in this function */
+ if (*lpcb < sizeof(RASENTRYNAMEW))
+ {
+ return ERROR_INVALID_SIZE;
+ }
+
+ *lpcb = 0; /* size of bytes needed to complete the call */
*lpcEntries = 0;
- return 0;
+
+ return 0; /* function executed correctly */
}
+/**************************************************************************
+ * RasGetConnectStatusA [RASAPI32.548 ]
+ */
DWORD WINAPI RasGetConnectStatusA(HRASCONN hrasconn, LPRASCONNSTATUSA lprasconnstatus)
{
FIXME("(%p,%p),stub!\n",hrasconn,lprasconnstatus);
- return 0;
+
+ if (NULL == hrasconn)
+ {
+ return ERROR_INVALID_HANDLE;
+ }
+
+ return 0; /* function executed correctly */
}
+/*************************************************************************
+ * RasGetConnectStatusW [RASAPI32.549]
+ */
DWORD WINAPI RasGetConnectStatusW(HRASCONN hrasconn, LPRASCONNSTATUSW lprasconnstatus)
{
FIXME("(%p,%p),stub!\n",hrasconn,lprasconnstatus);
- return 0;
+
+ if (NULL == hrasconn)
+ {
+ return ERROR_INVALID_HANDLE;
+ }
+
+ return 0; /* function executed correctly */
}
/**************************************************************************
@@ -188,8 +246,14 @@ DWORD WINAPI RasGetEntryDialParamsW(
*/
DWORD WINAPI RasHangUpA( HRASCONN hrasconn)
{
- FIXME("(%p),stub!\n",hrasconn);
- return 0;
+ FIXME("(%p),stub!\n",hrasconn);
+
+ if (NULL == hrasconn)
+ {
+ return ERROR_INVALID_HANDLE;
+ }
+
+ return 0; /* function executed correctly */
}
/**************************************************************************
@@ -198,7 +262,13 @@ DWORD WINAPI RasHangUpA( HRASCONN hrasconn)
DWORD WINAPI RasHangUpW(HRASCONN hrasconn)
{
FIXME("(%p),stub!\n",hrasconn);
- return 0;
+
+ if (NULL == hrasconn)
+ {
+ return ERROR_INVALID_HANDLE;
+ }
+
+ return 0; /* function executed correctly */
}
/**************************************************************************
@@ -246,23 +316,72 @@ DWORD WINAPI RasEnumAutodialAddressesW(LPWSTR *a, LPDWORD b, LPDWORD c)
DWORD WINAPI RasEnumDevicesA(LPRASDEVINFOA lpRasDevinfo, LPDWORD lpcb, LPDWORD lpcDevices)
{
FIXME("(%p,%p,%p),stub!\n",lpRasDevinfo,lpcb,lpcDevices);
- if (*lpcb < sizeof(RASDEVINFOA)) {
- *lpcb = sizeof(RASDEVINFOA);
- return ERROR_BUFFER_TOO_SMALL;
- }
+
+ /* size of buffer from lpcb should be consistent with the version
+ * to be used in this function */
+ if (*lpcb < sizeof(RASDEVINFOA))
+ {
+ *lpcb = sizeof(RASDEVINFOA); /* report what the size should be */
+ return ERROR_BUFFER_TOO_SMALL;
+ }
+
+ if ((NULL == lpcb) ||
+ (NULL == lpcDevices) )
+ {
+ return ERROR_INVALID_PARAMETER;
+ }
+
+ /* check to see if we are able to check the type of struct */
+ if ((NULL == lpRasDevinfo) || /* order dependent null check!! */
+ (lpRasDevinfo->dwSize != sizeof(RASDEVINFOA)) )
+ {
+ return ERROR_INVALID_USER_BUFFER;
+ }
+
+ /* a virtmodem? atleast report it correctly if
+ * we're gonna try and have one */
+ *lpcb = sizeof(RASDEVINFOA); /* number of bytes needed to enumerate devices */
+ *lpcDevices = 1; /* 1 ras device found */
+
/* honor dwSize ? */
strcpy(lpRasDevinfo->szDeviceType, RASDT_Modem);
strcpy(lpRasDevinfo->szDeviceName, "WINE virtmodem");
- return 0;
+
+ return 0; /* function executed correctly */
}
/**************************************************************************
* RasEnumDevicesW [RASAPI32.20]
*/
-DWORD WINAPI RasEnumDevicesW(LPRASDEVINFOW a, LPDWORD b, LPDWORD c)
+DWORD WINAPI RasEnumDevicesW(LPRASDEVINFOW lpRasDevinfo, LPDWORD lpcb, LPDWORD lpcDevices)
{
- FIXME("(%p,%p,%p),stub!\n",a,b,c);
- return 0;
+ FIXME("(%p,%p,%p),stub!\n",lpRasDevinfo,lpcb,lpcDevices);
+
+ /* size of buffer from lpcb should be consistent with the version
+ * to be used in this function */
+ if (*lpcb < sizeof(RASDEVINFOW))
+ {
+ *lpcb = sizeof(RASDEVINFOW); /* report what the size should be */
+ return ERROR_BUFFER_TOO_SMALL;
+ }
+
+ if ((NULL == lpcb) ||
+ (NULL == lpcDevices) )
+ {
+ return ERROR_INVALID_PARAMETER;
+ }
+
+ /* check to see if we are able to check the type of struct */
+ if ((NULL == lpRasDevinfo) || /* order dependent NULL check!! */
+ (lpRasDevinfo->dwSize != sizeof(RASDEVINFOW)) )
+ {
+ return ERROR_INVALID_USER_BUFFER;
+ }
+
+ *lpcb = 0; /* number of bytes of the RASDEVINFO buffer */
+ *lpcDevices = 0; /* no ras devices */
+
+ return 0; /* function executed correctly */
}
/**************************************************************************
--
1.4.4.4
More information about the wine-patches
mailing list