???? ID: 190987 - ????? ???????: 03 ?????? 2010 - ??????: 4.0

????????? ???????? ???????????? ?? ????? ???? ????

?????? ??????This article applies to a different operating system than the one you are using. Article content that may not be relevant to you is disabled.

?? ????? ??

??? ?? ??????? ???? | ??? ?? ??????? ????

??????

?? ???? ????? ???? ?? ?? ???? ????? ?? ???????? ???????????? ????????? SQL ????? ?? ???????????? ??? ??, ?? ???? ????? ?????? ???? ?? ?? ???? SQL ????? ?? ??? ??????????? ???? ?? ??? ?????? ???????? ???????????? ????????? ?????

???????? ???????????? ????????? ??? SQL ????? ?? ??????????? ?? ????????? ???? ?? ??? ???? ????? ?? ????? ??? ?? SQL Server ???????? ?????? ????? excerpt ??:
???????? ???????????? ????????? ?? ???? ???????? ?????????, ??? SQL Server extending ?? ???? ??? ?????? ??? ?? ??? ???? ?? ????????-???? ????????? (DLL) ??? ??? ?????? ????????? ???? ?? ?? ????? ?????? ???????????? SQL ????? ?? ???? ???????? SQL ????? ?? ???? ????? ?? triggered ?? ????? ??????? ?? ???? ??? ????? ?????? ??? ?? ?????? ???????? (?????? ???????? ???????????? ??? ???? ????????? ?? ?????) ?? ??????? ???? SQL ????? ????? ?????? ???????? ???????????? (sp_addextendedproc) ?????? (sp_dropextendedproc) ?? ????, ?? (sp_helpextededproc) ?? ???? ??? ??????? ?????? ????? ?? ???????? ???????????? ????????? ?????
?? ???? ?? ???? DLL ????? ?? ??? ??? ????????? ???????? ????????? DLL ????? ?????: ??? ???? ??? ?? ?? ?????? ????? ??? ?? ?? ??? ??? ?????? ?? ???? ???? ???? ?? production-worthy ????????? ?? ?? ??? ??? thorough ??????? ?? ????? ???? ?? ??????? ?? ????? ???? ?? ??? ????????? ?????

??? ????????? ???????? ???????????? ?????, ?? ?? ?????? ?? ??? ????? ??????? ?? ???????? ??? ?? ?????? ?? ??????? ????, ?? ??? ??? ????? ?? ?????????? Windows?????? Jeffrey Richter:
  • ?????? 3, "?????????"
  • ?????? 4, "???????"
  • ?????? 10, "????? ?????????????"
  • ?????? 12, "???????? ???? ???????????"
  • ?????? 13, "????? ??????? ??????"
  • ?????? 16, "?????-???????? Structured"
?? ??????? ???????? ???????????? ?? ????? ?? ??? ??? ?? ??? ???????-????????? ????? ?? ??? ???? ???? ?? ???? ??? ???? ??????? ?? ??? ????????? ???????? ???Michael Howard ?? ????? LeBlanc ??? ??? ?? ???????? ?? ???? ??? ???? ??????? ?? ??? ????? Microsoft ??? ???? ?? ????:
HTTP://www.Microsoft.com/Products/Info/Product.aspx?view=22&pcid=ab0cdef1-acfe-71c1-d09b-06567808e1e7 (http://www.microsoft.com/products/info/product.aspx?view=22&pcid=ab0cdef1-acfe-71c1-d09b-06567808e1e7)

???????

???????? ????????? ????????? ??????????? complicated ???? ??; Microsoft Visual C ?? ??? ?? ?????? ?????? (?? ??????) exposes Opends60.lib ????? ?? ???? ???? ??? ?? ?? C++ ???? DLL ?? ?? ??? ?? ?? ????? ????sp_addextendedproc???????? ????????? ????????? ?????? ?? ??? ?? ?????? DLL ?? ??????? ???? ?? ???? ?????XP,xp_dblib, ??xp_odbc????? ?????? ?? ??? SQL Server ?????????? ?? ?????? ??? ???? SQL ????? ?????????? ?? ?????? ?? ????? ??, ????? Microsoft ??? ???? ?? SQL Server ????? ?? ????:
HTTP://www.Microsoft.com/SQL/default.mspx (http://www.microsoft.com/sql/default.mspx)
???????? ???????????? ????????? ????? ??????? ??? ??????? ???, ?? ?????? ?????????? (SA) ??? ???? ????? ?? ??????? ?? ???????? ???? ???? ???

?? ?? ???? DLL ???????, ????????? ???? ?? ?? ??????? ?????? ?? ??? ?? ?? ??? 8.3 ???????? ????? ?????? ??????

???? ??????? ?? ???, Microsoft ?????? ??? ??? ???? ????? ?? ??? ????? ???? ?????? ????? ????::
151596  (http://support.microsoft.com/kb/151596/ ) ????????? ?????? ?????????: "DLL 'xxx.dll' ???? ???? ??"

??? ?????

SQL ????? ????? LoadLibrary, GetModuleHandle ?? GetProcAddress ????????? ?????? ?? ??? ???? ???? ??????? ???? ?? ???, ?? ???? ??? ??? passes ?????? ??? SRVPROC ??????? DLL SRVPROC ?????? ?? ????? ????, ?? ??? ?? ???????? ?? ??? ???? ???? ?? ????? ?? ??? ?? ???????? ??????? ???? ?? ??? ???? ????? ???? ?????? ???????? ?? ???? ????

??? DLL ?? ??? ??? ?? ?????? ????????? ?? ??? ????? ?? ??? ??? ????????? ???????? ????????? ?? ????? ??? ????????? ?? SQL Server. ??? ?? ????? ???????? ???? ?? ?? ?????? ?? ???? ??? DLL ?? ??????? ??? improperly ?? ??, ??? ?? ????????? adversely ???????? ?? ???? ???? ?? ????????? ???? ?? DLL ????? ?? ????????? ??? ???? ???? thorough ??????? ???? ?????? ??? ?? ?? ?????? ???????? ?? ????????? ???????? ????????? ???? ?? adversely ??? SQL Server ???, ?? ???? ?????? ??? ?? ?????? ??????

?????? ?? ???, ?? ????? ?? ???? Microsoft Visual C ?? Microsoft Visual C++ ???????? ???? ??-?? DevStudio ??????? ????? ?? ???? ?? ??????? ???? ??? ????????? COM ????? ?? DLL ??? ??? ?? ???? ??? ??????? ???? ???? ??? ??, ?? ????????? adversely ???????? ?? ???? ????

??????:

   char strName[31] = "";
   strncpy(strName, "Bob", 35); //  <-- Incorrect length
				
In this example, you are incorrectly copying data past the end of thestrNamebuffer. The documentation for thestrncpyroutine states that it will copy the second string into thestrNameparameter, and then zero fill the rest of the buffer. Therefore, the example is writing 35 bytes, even when the second string is 3 bytes in length. Thestrncpyroutine most likely will not cause an access violation because you are still in the process address space. ??? ??, ???????? ?? ???? ?? ???? ??? ????? ?? ????? ?? ?????? ?????? ??????, ?? ????????? ?? ????????? ??????? ???? ??? ????? SQL ????? ????????? ?? ????? ??? mistake ?? ?? ?????? ?? ?????????? ?????? SQL Server ?????? ????? ?? ???? ??, ??, ??? ?? ?? ???? ?? ?????? ????? ????? ?? ??????? ?? SQL ????? ???? ????????? ??????? ?? ?????? ??? ??? ??, ????? ?? ???? ?? ????? ???????? ?? ??? ???

SQL ????? ??? ????? ???????? ???? ?? ?????? ???? ??? ????????? ???????? ????????? ?? invocation ?? ?? ?????? ???? / ????? ?? ??? ?? ?? wrapped ??, ?? ??? ??? ?? ????? ??????? ?????? correctness ?? ???? ???? ???? ?? ??? ?? ?? ??????? ?? ?? ?? ?? ?????? ???? / ????? ?? ??? ?? ?? ?? ?????? ????/catch ?? ???? ??? ?? ?????? ???? ???? ?? ??? ?????????? ??? ?????, ??? ???? ???? ?? ????? unwinding ?????????? ?? ????

?????? leaks

??? ????????? ?? ???? ?? ?????? ???? ?????? ??????, ?? ?????, ?? ???? ???? ?????? ?? ???? ???? ?? ??? ?????? ??? ??? ??? DLL ??????? ???? ?? ???? ????????? ???? ?? ?? DLL ?? ?????? ??? ?????? ??? ???? ?? ??? paramount ??? ?? ?????? ?? ???????? ?? ????? ???? ??? ??? ????? ?????, altered ???????? ?? ???? ??? ?????? ?? ??? ??? ?????? ?? ??? ??????? ????

??????? ?????

Microsoft ??????? ????? ????? (IIS) ?? Microsoft SQL Server ???? ?????????, ????? ??????, ??????-????? ???? ????????? ???? ???? ???? ?? ?? ?? ?? ??????? ?? ???? ??? ???? DLL ?????? ??????? ?? ??? ???, particularly ?? ?? ?? ???? ???????? ?? ?? ???? ???????? ??? ???? ???? ?? ?? ??? ?? ???? ??? ??????? ???? ??????? DLL (XPROC, ISAPI) ?? ???? ????????? ????? ?? ????? ????? ?????? ????? ?????? usefulness ????? ??????? ?????? (TLS) ?? ?? ????? ?? ???? ????

????????? ???? ?? ??? ??? ?? ??? ?????-???????? ?? re-entrant ?? ??????-????? ???? ??-???? ????????? ?? ???? ????, ?? ????????? ???? ?? ??? ???????? DLL ????? ??? ?? ??? ?????-???????? ??? ????? ???????

????? ??????? ?????? ?? ????? ??????? ???????? ?? ?? ??????? ???? ?? ???? ??? ???? ??????? ?? ??? Microsoft ???????? ??? ???? ????? ?? ??? ????? ???? ?????? ?? ????? ????:
163449  (http://support.microsoft.com/kb/163449/ ) ????????? ???????? ????????? ??? ????? ??????? ?????? ?? ?????

?????? ????? ????????

?? ?????? ????? ?????? ???????? ??? ?? ?????? ???? ?????? ????? ????????? ?? ??? ??? DLL ??? ???????? ????????? ????? ???? ??? ?????? ?? ???? ?????? SQL ????? ????? ????????? ??? ???? ?? ?????? ???? ?? ????? ??? DLL ?????? ?? ???? ??? ?? ????? ?????? ?? ????? ???? ?? ??? ??? ????? ??? ??, ?? ?? DLL ??? ??????? ???? ??? ??? ?? ??????? ?????? ????? ?????? handlers ??????? ???? ?????

???? ????????? ??? ???????? ????? ?? ??? ????? ????? ??? ??? ??, ??? DLL ?? ????? ??????? ?? ???? ??, ?? ??????? ???? ????? naked ??? ??? ????? ???? ??? ?????? ?? ??????? / ?? ??? ?? ?? ?? ???? ?? ?????? ????/catch ??? ?????, ????? ?? ???? ???????? ???????? ?????? ?? ??????? ??? ????? ?????? ????? ??? ????? ?? unhanded ?? ????? ????????? ???? ?? ??? ???? ???? ???? ??? ??? ????, DLL ??? ???? ???? ?? ????????? ?? ????? ?? ?? ?? ?? ?????? ?? ?????? ?? ???? ????????? ???? ?? ??? ??? ????? ????? ??????

SQL ????? ?? ?????? SQL ????? ??? ?????? DLL ?? ??????? ?? ??? ???? ??? ?? ???? ???? ?? ????????? ???????? ????????? ????? ??? ?? ?? ?????? DLL ?? ??????? ?? ??? ?? ???? ???? ???? ??????

?????? ???????

?????? ??????? ??? ?? ?? ?? ????????? ???????? ????????? ?? SQL ????? ?? ??? ?? ?? ?? ?? ???????? ?? ??????? ????? ??? ?? ??? ????? ???? ??? ???xp_dblib, ??xp_odbc?????, ?????? SQL Server ?????????? ?? ?????? ?? ??? ????? ????

?? ???? ????? ???? ?? ?????? ??????? ?? ???? ???? ?????? ??????? ?? ??? ?? ?????? ?? ?? ?? ??? ??? ??????? ?? ?? ????? ??? ??? ????????? ????? ??? ?????? ?? ???, suppose ????????? ???????? ????????? ?????? ?????? ?? ??? ?????? ???? ?????? ???? ??? ?????? ??????? ?????? ?????? ?? ??? ??? ??? ?? ???? ???? ?? ?????? ???? ??? ???????, ??? ??????? ???? ?? ??? ??? ?????? ??? ???? ?????????????? ??? ?? ???? ?????? ??????? ?? ??????????? ???? ?? ??? diligent care ???? ??? ??, ?? ?? ?? ?????????? ?????? ?? ??????? ???? ?? ???, ?? SRV_GOTATTENTION, ?? ???? ???? ?? ??? ?? ??????? ?? ???? ?? ????? ??????
SQL Server 6.5 ?? SQL ????? ?? ??? builds ?????? ????? ??????? ??? ?????srv_getbindtoken, ??sp_bindsession?? ??????????? ?? ?????? ?????? ??????? ??? ??????? ???? ?? ??? ???????? ???? ????? ??????? ????????? ?? ?? ?? ????? ?? ??? ???? ???? ?? ??? ?? ????? ??? ??? ??? ?? ??????? ??????????????? avoided ???? ?? ???? ???

???:SQL ????? ???? ?? ?????? ???? ?????? ??????? ????? ???? ???

????? ???????? ?? ???? ??? ???? ??????? ?? ??? ?????? ?? Microsoft ???????? ??? ????? ?? ??? ????? ???? ???????? ?? ????? ????:
162361  (http://support.microsoft.com/kb/162361/ ) SQL ????? 6.x ????????? ?????? ?? ??? ???? ?? ?? ?????
180775  (http://support.microsoft.com/kb/180775/ ) SQL ????? ?????? ?? ??????? ??????

????????? ?? ?????

?????? ??????? ?? ?? ??????? ???????? ????????? SQL ????? ?? ??? ?? ?? ???? ???? ???????? ?? ???? ????? ???? ???? ????? ?? ??? ??? ??????? ????? ?? ?? ???? ???? facet ??? ????????? ?? ??????? ?? ???????? ???

??? ?? DB ????????? ?? ????? ?? ??? ???, ?? ??-????????? ?????? ?? ????? handlers ?? ????? ???? ?????? SQL ????? ??????? ????? handlers ?? ????????? ???? ?? ?? ??????? ???????? ????????? ?????? ???????????? ???? ???? ?????? -????????? ?????? ?? ????? handlers ?? ?????-???????? ???? ?? ??? ????????? ???? ?????dbprocmsghandle, ??dbprocerrhandle????? ????? ?? ????

???????? ???? ?? ???? LOGINREC ??? ???????dbopen.

???? ????????? ??????? ??? DB ????????? ?? ????? ?? ???? ?? ???? ??? ???? ??????? ?? ??? Microsoft ???????? ??? ???? ????? ?? ??? ????? ???? ?????? ?? ????? ????:
174817  (http://support.microsoft.com/kb/174817/ ) Microsoft SQL Server DB-????????? extensibility ????? ??
????? ???? ?????? API ??? ?? ???srv_message_handler, ?? SQL ????? ?????? ??? ??? ??? ?? ???? ???????? ??????? ?? ???, Microsoft ?????? ??? ??? ???? ????? ?? ??? ????? ???? ?????? ????? ????::
164290  (http://support.microsoft.com/kb/164290/ ) FIX: Srv_message_handler ??? ????
DB ????????? ?????? ?????? ?? ???? ??? ?? ????? ???: ?? INT_EXIT ??? ??????? ?????? ??????? ?? ???? ?? ???? ???? ???????, ?? ??? ??? ???? ??, ?? ???? ????????? ?? ???? ?????? ?? ??? ??? ???? ???? ?? ?? ?? ?? ????????? ?? ???? ???? ?? ??? instructing ???? ?????, ?? ?????? ???? ???? ?? ???? ?? ??? ??? DLL ?????? ?? ???? ???? ?? IIS ?? SQL ????? ????????? ?? ????

Transact-SQL KILL

?????? ??????? ?? ??????? ???????? ????????? ???????? ?? ????? ???? ?? ????? ?? Transact SQL ??? ?? ????? ???????? ??? ??? KILL ??? ?? ?????? Transact-SQL ??, ??????? ??????? ???? ?????? API ????? ??? Transact SQL ????? ?????? ?? ??? ????? ??? ??? ????????? ???????? ????????? SRV_GOTATTENTION ?? ??? ????? ????? ????? ?? ???????? ?? ???? ???? ?? ??? ??????? ?? ?????? ????? ?? ???? ???? ???????, SA ??? ???? ????? ???????? ????????? ???????? ????????? ?? ???? ?? ????? ?? Transact SQL ???? ?? ??? ????? ?? ???? ?????????? ?? ?? ?? ??? ??? ?? ????? ????? ??????? ?? ????? ????? ??????? ???????? ???????????? ??????? ???? ?? ??? ????? ?? Transact SQL ??? ?? ??????????? ?? ????????? ???? ?? ??? SQL Server ????? ?? ??? ?? ?????? ???????? ?????? (DCR) filed ?? ?? ???

??????? ????????

??? ? ??? DLL ??? ?? ?? ????????? ?? ??????? ?????? ?? ???????? ???? ???? ?????? ?? ???, SQL Server ????? ??? ?? ??? Win32 API ??? SetErrorMode ?????? ??????? ?? ??? ???? ?? ???? ????????? ???????? ????????? ?????? ??? ???? ??? SetErrorMode ?? ???? ????????? ??????? ??? ??????? ?? ??????? ????????? ????? ?? ??? ??? ?? ???? ??? ?? globally ???? ????????? ?? ???????? ???? ???; ????????? ???? ?? DLL ??? ?? ?? ????? ???? ???? ????

??? ??, ??? ????? ???? ???? (ODS) ????? ?? ??? ????? ?????? ???? ??? ??? ODS-?????? ????????? ??? ????? ?? ????????? ???????? ????????? ??? ????? ???? ???? ???? ?????? ?? ??? ???? ????? ????srv_init,srv_config,srv_handle, ??srv_errhandle. ?? ?????? ?? ??? ???? ?? SQL ????? installs ??? ?? ??????? ?? ????????? ?????? ?? ?????? ?? ??????? ?? ???? ???

Srv_Senddone

???????? ??? ??, SQL Server ???????? ??? ?? ???srv_senddone????????? ???????? ????????? ?? invocation ?? ?????? ?? SRV_DONE_FINAL ????? ?? ??? ???????? ????????? ????????? ????? ???????? ????????? ??????? ???? ?????? ?????????srv_senddoneSRV_DONE_FINAL ????? ?? ??? ???? ????, ???? ????? ???? ????? SRV_DONE_MORE ?????

???????? ???????

?? ?? ???? ?? ????? ?????? API ?? ???? ?????????? ?? ??? ????? ???, ?? ???? ?????? ????? ????????? ???? ?? ?? ??????? ???? ??? ?? ???????? ?? ?? ???? ?????? ?? ??srv_paramdata???????? ????????? ????????? ?? ??? ???? ?? ??? ????????? ???? ??? ?? ????? ????srv_paramlen?????????? ?? ??? ?? ????? ?? ??? ???????? ????????? ????????? ????? ???? ????? ???? ?????? ?? ?????? ???? ?? ???? ??; ?????? thoroughly ?? ??????? ?????

??????

Richter, Jeffrey.????? Windows. Redmond, WA: Microsoft ?????, 1997

Howard, Michael ?? ????? LeBlanc.???? ???????? ???, ????? ???????. Redmond, WA: Microsoft ?????, 2002?

???? ???? ???? ??:
  • Microsoft SQL Server 2000 Standard Edition
  • Microsoft SQL Server 2000 64-bit Edition
  • Microsoft SQL Server 7.0 Standard Edition
  • Microsoft SQL Server 6.5 Standard Edition
??????: 
kbhowtomaster kbprogramming kbmt KB190987 KbMthi
???? ?????? ???????????? ?????? ????????
??????????: ?? ???? ?? ???? ??????? ?? ????? ?? Microsoft ????-?????? ?????????? ?????? ?????? ???? ??? ??. Microsoft ???? ??? ????-???????? ?? ????-???????? ????? ?????? ?? ???? ???????? ???? ?? ???? ????? ????? ??? ?? ??? ?????? ?? ???? ???? ???? ??? ????? ??. ???????, ????-???????? ???? ????? ???? ???? ???? ???. ?????, ????????, ?????-???? ?? ??????? ?? ???????? ?? ???? ???, ???? ?? ??? ?????? ???? ???? ??? ????? ??? ?? ???? ??. Microsoft ??????? ??? ???? ?? ?????? ?? ??????????, ????????? ?? ??? ?????? ?? ???? ????? ?? ???? ???????? ?? ??? ???? ????? ?? ??? ????????? ???? ??. Microsoft ????-?????? ?????????? ?? ????? ?????? ?? ?? ??? ??.
?????????? ?? ??????? ????????? ??????? ??:190987  (http://support.microsoft.com/kb/190987/en-us/ )