Paul Vriens : inetcomm: Prevent possible dereferences (Coverity).

Alexandre Julliard julliard at winehq.org
Thu May 14 11:07:42 CDT 2009


Module: wine
Branch: master
Commit: e7f4f3b69cbf9a5e248fbf696f11c281f9f20a70
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=e7f4f3b69cbf9a5e248fbf696f11c281f9f20a70

Author: Paul Vriens <Paul.Vriens.Wine at gmail.com>
Date:   Thu May 14 09:18:08 2009 +0200

inetcomm: Prevent possible dereferences (Coverity).

---

 dlls/inetcomm/smtptransport.c |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/dlls/inetcomm/smtptransport.c b/dlls/inetcomm/smtptransport.c
index 91070b6..d17419f 100644
--- a/dlls/inetcomm/smtptransport.c
+++ b/dlls/inetcomm/smtptransport.c
@@ -732,7 +732,7 @@ static HRESULT WINAPI SMTPTransport_CommandMAIL(ISMTPTransport2 *iface, LPSTR ps
     SMTPTransport *This = (SMTPTransport *)iface;
     const char szCommandFormat[] = "MAIL FROM: <%s>\n";
     char *szCommand;
-    int len = sizeof(szCommandFormat) - 2 /* "%s" */ + strlen(pszEmailFrom);
+    int len;
     HRESULT hr;
 
     TRACE("(%s)\n", debugstr_a(pszEmailFrom));
@@ -740,6 +740,7 @@ static HRESULT WINAPI SMTPTransport_CommandMAIL(ISMTPTransport2 *iface, LPSTR ps
     if (!pszEmailFrom)
         return E_INVALIDARG;
 
+    len = sizeof(szCommandFormat) - 2 /* "%s" */ + strlen(pszEmailFrom);
     szCommand = HeapAlloc(GetProcessHeap(), 0, len);
     if (!szCommand)
         return E_OUTOFMEMORY;
@@ -758,7 +759,7 @@ static HRESULT WINAPI SMTPTransport_CommandRCPT(ISMTPTransport2 *iface, LPSTR ps
     SMTPTransport *This = (SMTPTransport *)iface;
     const char szCommandFormat[] = "RCPT TO: <%s>\n";
     char *szCommand;
-    int len = sizeof(szCommandFormat) - 2 /* "%s" */ + strlen(pszEmailTo);
+    int len;
     HRESULT hr;
 
     TRACE("(%s)\n", debugstr_a(pszEmailTo));
@@ -766,6 +767,7 @@ static HRESULT WINAPI SMTPTransport_CommandRCPT(ISMTPTransport2 *iface, LPSTR ps
     if (!pszEmailTo)
         return E_INVALIDARG;
 
+    len = sizeof(szCommandFormat) - 2 /* "%s" */ + strlen(pszEmailTo);
     szCommand = HeapAlloc(GetProcessHeap(), 0, len);
     if (!szCommand)
         return E_OUTOFMEMORY;
@@ -833,7 +835,7 @@ static HRESULT WINAPI SMTPTransport_CommandAUTH(ISMTPTransport2 *iface,
     SMTPTransport *This = (SMTPTransport *)iface;
     const char szCommandFormat[] = "AUTH %s\n";
     char *szCommand;
-    int len = sizeof(szCommandFormat) - 2 /* "%s" */ + strlen(pszAuthType);
+    int len;
     HRESULT hr;
 
     TRACE("(%s)\n", debugstr_a(pszAuthType));
@@ -841,6 +843,7 @@ static HRESULT WINAPI SMTPTransport_CommandAUTH(ISMTPTransport2 *iface,
     if (!pszAuthType)
         return E_INVALIDARG;
 
+    len = sizeof(szCommandFormat) - 2 /* "%s" */ + strlen(pszAuthType);
     szCommand = HeapAlloc(GetProcessHeap(), 0, len);
     if (!szCommand)
         return E_OUTOFMEMORY;




More information about the wine-cvs mailing list