SA-MP Forums Archive
mysq_function_query bug - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: mysq_function_query bug (/showthread.php?tid=403216)



mysq_function_query bug - GiamPy. - 29.12.2012

I am executing this query with the R7 plugin version of BluG.
I am using Centos and it gives me this error, and the server crashes.

pawn Код:
CMD:vcreate(playerid, params[])
{
    if(playerVariables[playerid][pAdminLevel] >= 4)
    {

        new
            Float:playerPos[4],
            vehicleModel,
            vehicleColor1,
            vehicleColor2,
            vehiclePlate[15];
           
        if(sscanf(params, "iii", vehicleModel, vehicleColor1, vehicleColor2))
            return SendClientMessage(playerid, COLOR_GREY, SYNTAX_MESSAGE"/vcreate [model id] [color 1] [color 2]");
           
        if(!(0 <= vehicleColor1 <= 255 && 0 <= vehicleColor2 <= 255))
            return SendClientMessage(playerid, COLOR_GREY, "INVALID COLOR SPECIFIED");

        new LetterList[22][] =
        {
            "A", "C", "D", "E", "F", "G", "H", "J", "K", "L", "M", "N", "P", "Q", "R", "T", "U", "V", "W", "X", "Y", "Z"
        };
       
        format(vehiclePlate, sizeof(vehiclePlate), "%d%d%d %s%s%s",
        random(9), random(9), random(9),
        LetterList[random(sizeof(LetterList))], LetterList[random(sizeof(LetterList))], LetterList[random(sizeof(LetterList))]);

        GetPlayerPos(playerid, playerPos[0], playerPos[1], playerPos[2]);
        GetPlayerFacingAngle(playerid, playerPos[3]);
       
        new createdCar = CreateVehicle(vehicleModel, playerPos[0], playerPos[1]+3, playerPos[2], playerPos[3], vehicleColor1, vehicleColor2, 500000);

        format(szLargeString, sizeof(szLargeString), "INSERT INTO privateveh (vModel, vColor1, vColor2, vPrice, vOwner, vPosX, vPosY, vPosZ, vPosA, vPlate) VALUES(%d, %d, %d, -1, 'Unknown', %f, %f, %f, %f, '%s')",
        vehicleModel, vehicleColor1, vehicleColor2, playerPos[0], playerPos[1], playerPos[2], playerPos[3], vehiclePlate);
       
        mysql_function_query(databaseConnection, szLargeString, false, "OnFinishCreateVehicle", "iiiiis[15]ffff", playerid, createdCar, vehicleModel, vehicleColor1, vehicleColor2, vehiclePlate, playerPos[0], playerPos[1], playerPos[2], playerPos[3]);

    } else
        return SendClientMessage(playerid, COLOR_RED, "YOU ARE NOT AUTHORIZED TO USE THIS COMMAND");
   
    return 1;
}
I have made a print debug and it stops at the mysql_function_query.
This is OnFinishCreateVehicle:

pawn Код:
public OnFinishCreateVehicle(playerid, vehicleid, model, color1, color2, plate[], Float: X, Float: Y, Float: Z, Float: A) {
    new insertid = mysql_insert_id();
   
    vInfo[vehicleid][vSQLID]            = insertid;
    vInfo[vehicleid][vModel]            = model;
    vInfo[vehicleid][vColor1]           = color1;
    vInfo[vehicleid][vColor2]           = color2;
    vInfo[vehicleid][vPrice]            = -1;
    vInfo[vehicleid][vPosX]             = X;
    vInfo[vehicleid][vPosY]             = Y;
    vInfo[vehicleid][vPosZ]             = Z;
    vInfo[vehicleid][vPosA]             = A;

    vInfo[vehicleid][vPaintJ]           = -1;
    vInfo[vehicleid][vLocked]           = 0;
    vInfo[vehicleid][vFaction]          = 0;
    vInfo[vehicleid][vJob]              = 0;
//  vInfo[vehicleid][vEngine]           = 1000.0;
    vInfo[vehicleid][vFuel]             = 100.0;
    vInfo[vehicleid][vStarted]          = 0;
    vInfo[vehicleid][vTrunkSlots][0]    = 0;
    vInfo[vehicleid][vTrunkSlots][1]    = 0;
    vInfo[vehicleid][vTrunkSlots][2]    = 0;
    vInfo[vehicleid][vTrunkSlots][3]    = 0;
    vInfo[vehicleid][vTrunkSlots][4]    = 0;

    vInfo[vehicleid][vTrunkAmmo][0]     = 0;
    vInfo[vehicleid][vTrunkAmmo][1]     = 0;
    vInfo[vehicleid][vTrunkAmmo][2]     = 0;
    vInfo[vehicleid][vTrunkAmmo][3]     = 0;
    vInfo[vehicleid][vTrunkAmmo][4]     = 0;

    vInfo[vehicleid][vBuyable]          = 0;
    vInfo[vehicleid][vStarted]          = 0;
    vInfo[vehicleid][dome]              = 0;
    vInfo[vehicleid][domeX]             = 0;
    vInfo[vehicleid][domeY]             = 0;
    vInfo[vehicleid][domeZ]             = 0;
    vInfo[vehicleid][domeRX]            = 0;
    vInfo[vehicleid][domeRY]            = 0;
    vInfo[vehicleid][domeRZ]            = 0;
    vInfo[vehicleid][policebar]         = 0;
    vInfo[vehicleid][policebarX]        = 0;
    vInfo[vehicleid][policebarY]        = 0;
    vInfo[vehicleid][policebarZ]        = 0;
    vInfo[vehicleid][policebarRX]       = 0;
    vInfo[vehicleid][policebarRY]       = 0;
    vInfo[vehicleid][policebarRZ]       = 0;
    vInfo[vehicleid][vSprunk]           = 0;
    vInfo[vehicleid][vCream]            = 0;
    vInfo[vehicleid][vRadio]            = 0;
    vInfo[vehicleid][vRadioStation]     = 0;

    vInfo[vehicleid][vInsurance]        = 0;
    vInfo[vehicleid][vAlarm]            = 0;
    vInfo[vehicleid][vLock]             = 0;
    vInfo[vehicleid][vImmobilizer]      = 0;
    vInfo[vehicleid][vTimesDestroyed]   = 0;

    for(new i = 0; i < MAX_VEH_MODS; ++i) vMods[vehicleid][i] = 0;
    strmid(vInfo[vehicleid][vOwner], "Unknown", 0, 20, 20);
    strmid(vInfo[vehicleid][vPlate], plate, 0, 32, 32);

    SavePrivVeh(vehicleid);

    format(szMediumString, sizeof(szMediumString), "Vehicle created: %d,  Model: %s, Plate: %s", vehicleid, VehicleNames[vInfo[vehicleid][vModel] - 400], vInfo[vehicleid][vPlate]);
    SendClientMessage(playerid, COLOR_RED, szMediumString);

    format(szMediumString, sizeof(szMediumString), "[A]: %s(%d) created the vehicle %s. [ModelID: %i, VehID: %i, SQLID: %i]", GetPlayerNameEx(playerid), playerid, VehicleNames[vInfo[vehicleid][vModel] - 400], model, vehicleid, insertid);
    submitToAdmins(szMediumString, COLOR_LIGHTRED);

    new engine, lights, alarm, doors, bonnet, boot, objective;
    GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
    SetVehicleParamsEx(vehicleid, 0, lights, alarm, doors, bonnet, boot, 0);
    SetVehicleNumberPlate(vehicleid, plate);

    return 1;
}
This is what the terminal says:

Quote:

*** buffer overflow detected ***: ./samp03svr terminated
======= Backtrace: =========
/lib/libc.so.6(__fortify_fail+0x4d)[0xc927ad]
/lib/libc.so.6[0xc907ea]
/lib/libc.so.6[0xc8ff18]
/lib/libc.so.6(__overflow+0x4a)[0xc059aa]
/lib/libc.so.6(__printf_fp+0x148c)[0xbdd89c]
/lib/libc.so.6(_IO_vfprintf+0x175a)[0xbd81ba]
/lib/libc.so.6(__vsprintf_chk+0xa7)[0xc8ffc7]
/lib/libc.so.6(__sprintf_chk+0x2d)[0xc8ff0d]
plugins/mysql.so(_ZN7Natives22n_mysql_query_callbackEP6tag AMXPi+0x2ea)[0x8f6b1a]
./samp03svr[0x80954a4]
plugins/crashdetect.so(_ZN11crashdetect13DoAmxCallbackEiPi S0_+0x73)[0x4af9d5]
plugins/crashdetect.so(+0x181ca)[0x4b31ca]
plugins/crashdetect.so(amx_Exec+0x2fb)[0x4b7136]
plugins/crashdetect.so(_ZN11crashdetect9DoAmxExecEPii+0x72 )[0x4af8b4]
plugins/crashdetect.so(+0x18203)[0x4b3203]
./samp03svr[0x80dcc22]
./samp03svr[0x80954a4]
plugins/crashdetect.so(_ZN11crashdetect13DoAmxCallbackEiPi S0_+0x73)[0x4af9d5]
plugins/crashdetect.so(+0x181ca)[0x4b31ca]
plugins/crashdetect.so(amx_Exec+0x2fb)[0x4b7136]
plugins/crashdetect.so(_ZN11crashdetect9DoAmxExecEPii+0x72 )[0x4af8b4]
plugins/crashdetect.so(+0x18203)[0x4b3203]
./samp03svr[0x80a4da2]
./samp03svr[0x80afcca]
./samp03svr[0x80733b1]
./samp03svr[0x80734a2]
./samp03svr[0x807d2b0]
./samp03svr[0x80ad426]
./samp03svr[0x80ad652]
./samp03svr[0x80a8fb3]
/lib/libc.so.6(__libc_start_main+0xe6)[0xbacce6]
./samp03svr[0x804b491]
======= Memory map: ========
00110000-0019c000 r-xp 00000000 fd:00 920558 /root/Scrivania/samp03/plugins/streamer.so
0019c000-0019d000 rw-p 0008b000 fd:00 920558 /root/Scrivania/samp03/plugins/streamer.so
0019d000-0019e000 rw-p 00000000 00:00 0
0019e000-001a5000 r-xp 00000000 fd:00 405595 /lib/librt-2.12.so
001a5000-001a6000 r--p 00006000 fd:00 405595 /lib/librt-2.12.so
001a6000-001a7000 rw-p 00007000 fd:00 405595 /lib/librt-2.12.so
001a7000-001be000 r-xp 00000000 fd:00 405577 /lib/libnsl-2.12.so
001be000-001bf000 r--p 00016000 fd:00 405577 /lib/libnsl-2.12.so
001bf000-001c0000 rw-p 00017000 fd:00 405577 /lib/libnsl-2.12.so
001c0000-001c2000 rw-p 00000000 00:00 0
001c2000-00337000 r-xp 00000000 fd:00 149661 /usr/lib/libcrypto.so.1.0.0
00337000-00338000 ---p 00175000 fd:00 149661 /usr/lib/libcrypto.so.1.0.0
00338000-00346000 r--p 00175000 fd:00 149661 /usr/lib/libcrypto.so.1.0.0
00346000-0034c000 rw-p 00183000 fd:00 149661 /usr/lib/libcrypto.so.1.0.0
0034c000-0034f000 rw-p 00000000 00:00 0
0034f000-00398000 r-xp 00000000 fd:00 405547 /lib/libfreebl3.so
00398000-00399000 r--p 00048000 fd:00 405547 /lib/libfreebl3.so
00399000-0039a000 rw-p 00049000 fd:00 405547 /lib/libfreebl3.so
0039a000-0039e000 rw-p 00000000 00:00 0
0039e000-003db000 r-xp 00000000 fd:00 407338 /lib/libgssapi_krb5.so.2.2
003db000-003dc000 r--p 0003c000 fd:00 407338 /lib/libgssapi_krb5.so.2.2
003dc000-003dd000 rw-p 0003d000 fd:00 407338 /lib/libgssapi_krb5.so.2.2
003dd000-003e0000 r-xp 00000000 fd:00 407333 /lib/libcom_err.so.2.1
003e0000-003e1000 r--p 00002000 fd:00 407333 /lib/libcom_err.so.2.1
003e1000-003e2000 rw-p 00003000 fd:00 407333 /lib/libcom_err.so.2.1
003e2000-0040b000 r-xp 00000000 fd:00 407342 /lib/libk5crypto.so.3.1
0040b000-0040c000 ---p 00029000 fd:00 407342 /lib/libk5crypto.so.3.1
0040c000-0040d000 r--p 00029000 fd:00 407342 /lib/libk5crypto.so.3.1
0040d000-0040e000 rw-p 0002a000 fd:00 407342 /lib/libk5crypto.so.3.1
0040e000-00423000 r-xp 00000000 fd:00 405593 /lib/libresolv-2.12.so
00423000-00424000 ---p 00015000 fd:00 405593 /lib/libresolv-2.12.so
00424000-00425000 r--p 00015000 fd:00 405593 /lib/libresolv-2.12.so
00425000-00426000 rw-p 00016000 fd:00 405593 /lib/libresolv-2.12.so
00426000-00428000 rw-p 00000000 00:00 0
00428000-00431000 r-xp 00000000 fd:00 407346 /lib/libkrb5support.so.0.1
00431000-00432000 r--p 00008000 fd:00 407346 /lib/libkrb5support.so.0.1
00432000-00433000 rw-p 00009000 fd:00 407346 /lib/libkrb5support.so.0.1
00433000-00435000 r-xp 00000000 fd:00 407335 /lib/libkeyutils.so.1.3
00435000-00436000 r--p 00001000 fd:00 407335 /lib/libkeyutils.so.1.3
00436000-00437000 rw-p 00002000 fd:00 407335 /lib/libkeyutils.so.1.3
00437000-00454000 r-xp 00000000 fd:00 395061 /lib/libselinux.so.1
00454000-00455000 r--p 0001c000 fd:00 395061 /lib/libselinux.so.1
00455000-00456000 rw-p 0001d000 fd:00 395061 /lib/libselinux.so.1
00456000-00462000 r-xp 00000000 fd:00 405583 /lib/libnss_files-2.12.so
00462000-00463000 r--p 0000b000 fd:00 405583 /lib/libnss_files-2.12.so
00463000-00464000 rw-p 0000c000 fd:00 405583 /lib/libnss_files-2.12.so
00464000-00467000 r-xp 00000000 fd:00 920556 /root/Scrivania/samp03/plugins/MapAndreas.so
00467000-00468000 r--p 00002000 fd:00 920556 /root/Scrivania/samp03/plugins/MapAndreas.so
00468000-00469000 rw-p 00003000 fd:00 920556 /root/Scrivania/samp03/plugins/MapAndreas.so
00469000-00475000 r-xp 00000000 fd:00 920581 /root/Scrivania/samp03/plugins/sscanf.so
00475000-00476000 rw-p 0000c000 fd:00 920581 /root/Scrivania/samp03/plugins/sscanf.so
0047d000-0049a000 r-xp 00000000 fd:00 394543 /lib/libgcc_s-4.4.6-20120305.so.1
0049a000-0049b000 rw-p 0001d000 fd:00 394543 /lib/libgcc_s-4.4.6-20120305.so.1
0049b000-004c0000 r-xp 00000000 fd:00 920559 /root/Scrivania/samp03/plugins/crashdetect.so
004c0000-004c1000 rw-p 00024000 fd:00 920559 /root/Scrivania/samp03/plugins/crashdetect.so
0051f000-00572000 r-xp 00000000 fd:00 151182 /usr/lib/libssl.so.1.0.0Abortito (core dumped)

This is what windows gave testing in local:
Quote:

[17:26:08] [debug] Server crashed while executing rr.amx
[17:26:08] [debug] AMX backtrace:
[17:26:08] [debug] #0 native mysql_function_query () [003e8f00] from mysql.DLL
[17:26:08] [debug] #1 0006cf70 in public cmd_vcreate () from rr.amx
[17:26:08] [debug] #2 native CallLocalFunction () [00472c00] from samp-server.exe
[17:26:08] [debug] #3 000009f0 in public OnPlayerCommandText () from rr.amx
[17:26:08] [debug] System backtrace:
[17:26:08] [debug] #0 77afe023 in ?? () from C:\Windows\SysWOW64\ntdll.dll
[17:26:08] [debug] #1 753814dd in ?? () from C:\Windows\syswow64\kernel32.dll
[17:26:08] [debug] #2 74e53c1b in ?? () from C:\Windows\WinSxS\x86_microsoft.vc90.crt_1fc8b3b9a 1e18e3b_9.0.30729.6161_none_50934f2ebcb7eb57\MSVCR 90.dll
[17:26:08] [debug] #3 003e9196 in ?? () from C:\Users\Amministratore\Documents\Documenti Personali\SAMP\SCRIPT\Role Play\Server\plugins\mysql.DLL
[17:26:08] [debug] #4 004010b6 in ?? () from C:\Users\Amministratore\Documents\Documenti Personali\SAMP\SCRIPT\Role Play\Server\samp-server.exe
[17:26:08] [debug] #5 726b3c32 in ?? () from C:\Users\Amministratore\Documents\Documenti Personali\SAMP\SCRIPT\Role Play\Server\plugins\crashdetect.DLL
[17:26:08] [debug] #6 726b6076 in ?? () from C:\Users\Amministratore\Documents\Documenti Personali\SAMP\SCRIPT\Role Play\Server\plugins\crashdetect.DLL
[17:26:08] [debug] #7 726ac05a in ?? () from C:\Users\Amministratore\Documents\Documenti Personali\SAMP\SCRIPT\Role Play\Server\plugins\crashdetect.DLL
[17:26:08] [debug] #8 726b3c5e in ?? () from C:\Users\Amministratore\Documents\Documenti Personali\SAMP\SCRIPT\Role Play\Server\plugins\crashdetect.DLL
[17:26:08] [debug] #9 00472f0e in ?? () from C:\Users\Amministratore\Documents\Documenti Personali\SAMP\SCRIPT\Role Play\Server\samp-server.exe
[17:26:08] [debug] #10 004010b6 in ?? () from C:\Users\Amministratore\Documents\Documenti Personali\SAMP\SCRIPT\Role Play\Server\samp-server.exe
[17:26:08] [debug] #11 726b3c32 in ?? () from C:\Users\Amministratore\Documents\Documenti Personali\SAMP\SCRIPT\Role Play\Server\plugins\crashdetect.DLL
[17:26:08] [debug] #12 726b6076 in ?? () from C:\Users\Amministratore\Documents\Documenti Personali\SAMP\SCRIPT\Role Play\Server\plugins\crashdetect.DLL
[17:26:08] [debug] #13 726ac05a in ?? () from C:\Users\Amministratore\Documents\Documenti Personali\SAMP\SCRIPT\Role Play\Server\plugins\crashdetect.DLL
[17:26:08] [debug] #14 726b3c5e in ?? () from C:\Users\Amministratore\Documents\Documenti Personali\SAMP\SCRIPT\Role Play\Server\plugins\crashdetect.DLL
[17:26:08] [debug] #15 0046d9d0 in ?? () from C:\Users\Amministratore\Documents\Documenti Personali\SAMP\SCRIPT\Role Play\Server\samp-server.exe




Re: mysq_function_query bug - GiamPy. - 29.12.2012

Fixed.