<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[[CodeGuard] Bad Parameter]]></title><description><![CDATA[<p>Huhu,</p>
<p>Ich habe eine Frage zu einer Codeguard Meldung</p>
<p>Ich habe folgende Funktion</p>
<pre><code class="language-cpp">//---------------------------------------------------------------------------
AnsiString __fastcall GameSpy::GetServerList(AnsiString handoff, AnsiString GSName, AnsiString Filter)
{
    int sockfd, ret;
    struct  hostent *host;
    struct sockaddr_in remote;
    char *packet = new char[10240];
    int pos;
    char *buf = new char[BUFSIZE];
    WSAData wsad;
    WSAStartup(MAKEWORD(1,1), &amp;wsad);

    sockfd = socket(AF_INET, SOCK_STREAM, IPPROTO_IP);

    if((host = gethostbyname(GAMESPY))== NULL)
    {
        ShowMessage(SockErrorMsg());
        return &quot;&quot;;
    }

    remote.sin_family = AF_INET;
    remote.sin_port = htons(28900);
    remote.sin_addr.s_addr =  *(unsigned long *)(host-&gt;h_addr);

    connect(sockfd, (struct sockaddr*)&amp;remote, sizeof(remote));

    ret = recv(sockfd, buf, BUFSIZE, 0);
    buf[ret] = 0;
    buf++;
    for(;*buf!=0x5C;buf++);
    buf++;
    for(;*buf!=0x5C;buf++);
    buf++;
    for(;*buf!=0x5C;buf++);
    buf++;
    unsigned char *response = gsseckey((unsigned char*)buf, (unsigned char*)handoff.c_str(), 0);
    char query[256];
    if(Filter.IsEmpty())
        sprintf(query, &quot;\\basic\\gamename\\%s\\validate\\%s\\final\\list\\\\gamename\\%s\\final\\&quot;,GSName.c_str(), response, GSName.c_str());
    else
        sprintf(query, &quot;\\basic\\gamename\\%s\\validate\\%s\\final\\list\\\\gamename\\%s\\where\\%s\\final\\&quot;,GSName.c_str(), response, GSName.c_str(), Filter.c_str());

    send(sockfd, query, strlen(query), 0);
    pos = 0;
    while(ret&gt;0)
    {
        ret = recv(sockfd, buf, BUFSIZE, 0);
        if(ret &gt; 0)
        {
            memcpy(packet+pos, buf, ret);
            pos += ret;
        }
        else if(ret &lt; 0)
        {
            ShowMessage(SockErrorMsg());
            return &quot;&quot;;
        }

    }
    packet[pos] = 0;

    closesocket(sockfd);

    AnsiString IpList;

    if(packet[0] != NULL)
        IpList = FormatIpList(packet, pos);

    delete[] buf;       //&lt;- Hier meldet sich der CodeGuard
    delete[] packet;    //&lt;- Hier mekkert der CG nicht rum

    return IpList;
}
//---------------------------------------------------------------------------
</code></pre>
<p>Der CodeGuard meldet mir folgendes</p>
<p>CodeGuard schrieb:</p>
<blockquote>
<p>Error 00083. 0x310010 (Thread 0x02F4):<br />
Bad parameter: A bad object array (0xEAE807) has been passed to the function.<br />
delete[](0x00EAE807)</p>
<p>Call Tree:<br />
0x0040F811(=MultiJoiner.exe:0x01:00E811) H:\DBSoftQuellen\svn projekte\multijoiner\klassen\gamespyclass.cpp#267<br />
0x00410CF1(=MultiJoiner.exe:0x01:00FCF1) H:\DBSoftQuellen\svn projekte\multijoiner\klassen\Thread.cpp#128<br />
0x00493DEF(=MultiJoiner.exe:0x01:092DEF)<br />
0x0049F9FA(=MultiJoiner.exe:0x01:09E9FA)<br />
0x77E565DA(=kernel32.dll:0x01:0155DA)</p>
<p>The object array (0x00EAE7F8) [size: 4096 bytes] was created with new[]<br />
Call Tree:<br />
0x0040F320(=MultiJoiner.exe:0x01:00E320) H:\DBSoftQuellen\svn projekte\multijoiner\klassen\gamespyclass.cpp#206<br />
0x00410CF1(=MultiJoiner.exe:0x01:00FCF1) H:\DBSoftQuellen\svn projekte\multijoiner\klassen\Thread.cpp#128<br />
0x00493DEF(=MultiJoiner.exe:0x01:092DEF)<br />
0x0049F9FA(=MultiJoiner.exe:0x01:09E9FA)<br />
0x77E565DA(=kernel32.dll:0x01:0155DA)</p>
<p>------------------------------------------</p>
</blockquote>
<p>Meine Frage ist nun wieso mekkert der CodeGuard an der Stelle wo ich</p>
<pre><code>delete [] buf
</code></pre>
<p>aufrufe. BUFFSZ ist mit 4096 im header #defined</p>
<p>bei der Freigabe zu packet gehts ja auch und beide werden mit new char[] erzeugt.</p>
<p>Hoffe mal einer von euch kann mir einen Tip geben wie ich das beheben kann.</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/113502/codeguard-bad-parameter</link><generator>RSS for Node</generator><lastBuildDate>Wed, 22 Jul 2026 09:30:46 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/113502.rss" rel="self" type="application/rss+xml"/><pubDate>Thu, 23 Jun 2005 13:52:27 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to [CodeGuard] Bad Parameter on Thu, 23 Jun 2005 13:52:27 GMT]]></title><description><![CDATA[<p>Huhu,</p>
<p>Ich habe eine Frage zu einer Codeguard Meldung</p>
<p>Ich habe folgende Funktion</p>
<pre><code class="language-cpp">//---------------------------------------------------------------------------
AnsiString __fastcall GameSpy::GetServerList(AnsiString handoff, AnsiString GSName, AnsiString Filter)
{
    int sockfd, ret;
    struct  hostent *host;
    struct sockaddr_in remote;
    char *packet = new char[10240];
    int pos;
    char *buf = new char[BUFSIZE];
    WSAData wsad;
    WSAStartup(MAKEWORD(1,1), &amp;wsad);

    sockfd = socket(AF_INET, SOCK_STREAM, IPPROTO_IP);

    if((host = gethostbyname(GAMESPY))== NULL)
    {
        ShowMessage(SockErrorMsg());
        return &quot;&quot;;
    }

    remote.sin_family = AF_INET;
    remote.sin_port = htons(28900);
    remote.sin_addr.s_addr =  *(unsigned long *)(host-&gt;h_addr);

    connect(sockfd, (struct sockaddr*)&amp;remote, sizeof(remote));

    ret = recv(sockfd, buf, BUFSIZE, 0);
    buf[ret] = 0;
    buf++;
    for(;*buf!=0x5C;buf++);
    buf++;
    for(;*buf!=0x5C;buf++);
    buf++;
    for(;*buf!=0x5C;buf++);
    buf++;
    unsigned char *response = gsseckey((unsigned char*)buf, (unsigned char*)handoff.c_str(), 0);
    char query[256];
    if(Filter.IsEmpty())
        sprintf(query, &quot;\\basic\\gamename\\%s\\validate\\%s\\final\\list\\\\gamename\\%s\\final\\&quot;,GSName.c_str(), response, GSName.c_str());
    else
        sprintf(query, &quot;\\basic\\gamename\\%s\\validate\\%s\\final\\list\\\\gamename\\%s\\where\\%s\\final\\&quot;,GSName.c_str(), response, GSName.c_str(), Filter.c_str());

    send(sockfd, query, strlen(query), 0);
    pos = 0;
    while(ret&gt;0)
    {
        ret = recv(sockfd, buf, BUFSIZE, 0);
        if(ret &gt; 0)
        {
            memcpy(packet+pos, buf, ret);
            pos += ret;
        }
        else if(ret &lt; 0)
        {
            ShowMessage(SockErrorMsg());
            return &quot;&quot;;
        }

    }
    packet[pos] = 0;

    closesocket(sockfd);

    AnsiString IpList;

    if(packet[0] != NULL)
        IpList = FormatIpList(packet, pos);

    delete[] buf;       //&lt;- Hier meldet sich der CodeGuard
    delete[] packet;    //&lt;- Hier mekkert der CG nicht rum

    return IpList;
}
//---------------------------------------------------------------------------
</code></pre>
<p>Der CodeGuard meldet mir folgendes</p>
<p>CodeGuard schrieb:</p>
<blockquote>
<p>Error 00083. 0x310010 (Thread 0x02F4):<br />
Bad parameter: A bad object array (0xEAE807) has been passed to the function.<br />
delete[](0x00EAE807)</p>
<p>Call Tree:<br />
0x0040F811(=MultiJoiner.exe:0x01:00E811) H:\DBSoftQuellen\svn projekte\multijoiner\klassen\gamespyclass.cpp#267<br />
0x00410CF1(=MultiJoiner.exe:0x01:00FCF1) H:\DBSoftQuellen\svn projekte\multijoiner\klassen\Thread.cpp#128<br />
0x00493DEF(=MultiJoiner.exe:0x01:092DEF)<br />
0x0049F9FA(=MultiJoiner.exe:0x01:09E9FA)<br />
0x77E565DA(=kernel32.dll:0x01:0155DA)</p>
<p>The object array (0x00EAE7F8) [size: 4096 bytes] was created with new[]<br />
Call Tree:<br />
0x0040F320(=MultiJoiner.exe:0x01:00E320) H:\DBSoftQuellen\svn projekte\multijoiner\klassen\gamespyclass.cpp#206<br />
0x00410CF1(=MultiJoiner.exe:0x01:00FCF1) H:\DBSoftQuellen\svn projekte\multijoiner\klassen\Thread.cpp#128<br />
0x00493DEF(=MultiJoiner.exe:0x01:092DEF)<br />
0x0049F9FA(=MultiJoiner.exe:0x01:09E9FA)<br />
0x77E565DA(=kernel32.dll:0x01:0155DA)</p>
<p>------------------------------------------</p>
</blockquote>
<p>Meine Frage ist nun wieso mekkert der CodeGuard an der Stelle wo ich</p>
<pre><code>delete [] buf
</code></pre>
<p>aufrufe. BUFFSZ ist mit 4096 im header #defined</p>
<p>bei der Freigabe zu packet gehts ja auch und beide werden mit new char[] erzeugt.</p>
<p>Hoffe mal einer von euch kann mir einen Tip geben wie ich das beheben kann.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/815677</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/815677</guid><dc:creator><![CDATA[Fox-Alpha]]></dc:creator><pubDate>Thu, 23 Jun 2005 13:52:27 GMT</pubDate></item><item><title><![CDATA[Reply to [CodeGuard] Bad Parameter on Thu, 23 Jun 2005 14:12:00 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">ret = recv(sockfd, buf, BUFSIZE, 0);
    buf[ret] = 0;
</code></pre>
<p>Hier schreibst du, wenn 4k ankommen die 0 hinter den gültigen Speicher</p>
<pre><code class="language-cpp">buf++;
    for(;*buf!=0x5C;buf++);
</code></pre>
<p>Sowas ist gefährlich. Was ist wenn das Pattern 0x5C nicht vorhanden ist?</p>
<pre><code class="language-cpp">unsigned char *response = gsseckey((unsigned char*)buf, (unsigned char*)handoff.c_str(), 0);
</code></pre>
<p>Was passiert hier?</p>
<pre><code class="language-cpp">char query[256];
[...]
sprintf(&quot;\\basic\\gamename\\%s\\validate\\%s\\final\\list\\\\gamename\\%s\\final\\&quot;,GSName.c_str(), response, GSName.c_str());
</code></pre>
<p>Solche Dinge sind gefährlich! Wie garantierst du das nicht überschreiten der 256 Zeichen?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/815760</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/815760</guid><dc:creator><![CDATA[junix]]></dc:creator><pubDate>Thu, 23 Jun 2005 14:12:00 GMT</pubDate></item><item><title><![CDATA[Reply to [CodeGuard] Bad Parameter on Thu, 23 Jun 2005 18:05:09 GMT]]></title><description><![CDATA[<p>Das ganze stammt aus einem freiem Code den ich in meinem Programm verwende. Lediglich eventuelle Anpassungen an die VCL habe ich gemacht.</p>
<p>Punkt 1 habe ich jetzt mit BUFFSZ-1 geändert, denke mal das geht in Ordnung.</p>
<p>Zu Punkt 2.</p>
<p>Soll ich da lieber den Code mit strtok bearbeiten ?</p>
<p>3. gsseckey prüft den empfangenen String und holt da einen Wert heraus der für die nächste Antwort benötigt wird.</p>
<p>Zu 4.<br />
Hast eigentlich recht.<br />
Bei deiner quotezeile ist dies allerdings irrelevant da diese eigentlich nice die 256 erreichen kann. Zwei Zeilen tiefer siehts allerdinsg anders aus. Der zusätzlich Parameter Filter kann doch länger sein bzw dafür sorgen das die Zeichenkette länger wird.<br />
Ich werde dasd nochmal ändern. Eventuell nutze ich da AnsiString oder sowas. Schliesslich habe ich ja den Builder und kann dann auch die VCL nutzen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/815933</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/815933</guid><dc:creator><![CDATA[Fox-Alpha]]></dc:creator><pubDate>Thu, 23 Jun 2005 18:05:09 GMT</pubDate></item><item><title><![CDATA[Reply to [CodeGuard] Bad Parameter on Thu, 23 Jun 2005 18:25:43 GMT]]></title><description><![CDATA[<p>Fox-Alpha schrieb:</p>
<blockquote>
<p>Zu Punkt 2.</p>
<p>Soll ich da lieber den Code mit strtok bearbeiten ?</p>
</blockquote>
<p>Ja vielleicht eher... oder strpos... Weiss nicht genau was da wohl das beste wäre... evtl. auch keine str-operation sondern irgendwas mem*?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/815950</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/815950</guid><dc:creator><![CDATA[junix]]></dc:creator><pubDate>Thu, 23 Jun 2005 18:25:43 GMT</pubDate></item><item><title><![CDATA[Reply to [CodeGuard] Bad Parameter on Fri, 24 Jun 2005 05:14:53 GMT]]></title><description><![CDATA[<p>Und die Fehlermeldung mit dem Bad Parameter vermeidet man, indem man buf auf seinen Ursprungswert zurücksetzt. Einfacher wäre natürlich ein zweiter Zeiger, den man dann manipulieren kann wie man will.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/816108</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/816108</guid><dc:creator><![CDATA[[[global:guest]]]]></dc:creator><pubDate>Fri, 24 Jun 2005 05:14:53 GMT</pubDate></item><item><title><![CDATA[Reply to [CodeGuard] Bad Parameter on Fri, 24 Jun 2005 06:24:37 GMT]]></title><description><![CDATA[<p>Oh, äh, stimmt, äh, das, äh, hatte ich wohl übersehen *hehe*</p>
]]></description><link>https://www.c-plusplus.net/forum/post/816132</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/816132</guid><dc:creator><![CDATA[junix]]></dc:creator><pubDate>Fri, 24 Jun 2005 06:24:37 GMT</pubDate></item></channel></rss>