Skip to content
Tcl Source Code Artifact [8f27ef47d6]
Login

Artifact [8f27ef47d6]

Artifact 8f27ef47d6eb2fd7945f79d94ab056b17523a394:

Ticket change [8f27ef47d6] - Ticket [2494093fffffffff|2494093fff] <i>buffer overflow in AppendUnicodeToUnicode() -&gt; SEGFAULT</i> status still Open with 4 other changes by matzek on 2009-02-02 17:45:04.
D 2009-02-02T17:45:04
J icomment peppered\sthe\scode\swith\sprintf()s\sagain\s...\son\sSolaris\srevealed:\n\n>>>\snumChars\s1073733632;\sualloc(numChars)\s2147467264\s>=\suallocated\s2147460096?\n>>>\s\sattempt\sto\sreallocate\s4294934528\n>>>\s\s\sreallocate\s2147476480\n>>>\s\snew\sbuffer\s@\s0x2109a0,\sold\swas\s@\s0x2109a0\n>>>\scopy\s8192\sfrom\s0x206970\sto\s0x8020a9b0\n\n>>>\snumChars\s1073737728;\sualloc(numChars)\s2147475456\s>=\suallocated\s2147476480?\n>>>\scopy\s8192\sfrom\s0x206970\sto\s0x8020c9b0\n\n>>>\snumChars\s1073741824;\sualloc(numChars)\s2147483648\s>=\suallocated\s2147476480?\n>>>\s\sattempt\sto\sreallocate\s0\n>>>\s\snew\sbuffer\s@\s0x1f6b28,\sold\swas\s@\s0x2109a0\n>>>\scopy\s8192\sfrom\s0x206970\sto\s0x801f4b38\n\n>>>\snumChars\s1073745920;\sualloc(numChars)\s2147491840\s>=\suallocated\s0?\n>>>\s\sattempt\sto\sreallocate\s16384\n>>>\s\snew\sbuffer\s@\s0x20a980,\sold\swas\s@\s0x1f6b28\n>>>\scopy\s8192\sfrom\s0x206970\sto\s0x8020a990\n\n>>>\snumChars\s1073750016;\sualloc(numChars)\s2147500032\s>=\suallocated\s16384?\n>>>\s\sattempt\sto\sreallocate\s32768\n>>>\s\snew\sbuffer\s@\s0x20a980,\sold\swas\s@\s0x20a980\n>>>\scopy\s8192\sfrom\s0x206970\sto\s0x8020c990\n\n>>>\snumChars\s1073754112;\sualloc(numChars)\s2147508224\s>=\suallocated\s32768?\n>>>\s\sattempt\sto\sreallocate\s49152\n>>>\s\snew\sbuffer\s@\s0x20a980,\sold\swas\s@\s0x20a980\n>>>\scopy\s8192\sfrom\s0x206970\sto\s0x8020e990\n\n>>>\snumChars\s1073758208;\sualloc(numChars)\s2147516416\s>=\suallocated\s49152?\n>>>\s\sattempt\sto\sreallocate\s65536\n>>>\s\snew\sbuffer\s@\s0x20a980,\sold\swas\s@\s0x20a980\n>>>\scopy\s8192\sfrom\s0x206970\sto\s0x80210990\n\nSo\sthere\sis\san\sentry\sthat\sshow\sthat\swe\sattempt\sto\sreallocate\s0\sbytes.\sThe\spreprocessor\sresult\sis\s...\n\n\s\s\s\snumChars\s=\sstringPtr->numChars\s+\sappendNumChars;\n\n\s\s\s\sif\s(\s(\s(\snumChars\s)\s*\ssizeof\s(\sTcl_UniChar\s)\s)\s>=\sstringPtr->uallocated)\s{\n\s\s\s\s\sstringPtr->uallocated\s=\s\s(\s(\s2\s*\snumChars\s)\s*\ssizeof\s(\sTcl_UniChar\s)\s);\ntmpString\s=\s\s(\sString\s*\s)\s(\s(\s(\sstringPtr\s->\suallocated\s)\s>\s2147483647\s-\s(\ssizeof\s(\sString\s)\s-\ssizeof\s(\sTcl_UniChar\s)\s+\s(\s0\s)\s)\s)\s?\s0\s:\sTcl_AttemptRealloc\s(\s(\schar\s*\s)\sstringPtr\s,\s(\sunsigned\s)\s(\ssizeof\s(\sString\s)\s-\ssizeof\s(\sTcl_UniChar\s)\s+\s(\s(\sstringPtr\s->\suallocated\s)\s?\s(\sstringPtr\s->\suallocated\s)\s:\ssizeof\s(\sTcl_UniChar\s)\s)\s)\s)\s);\nif\s(tmpString\s==\s\s0\s)\s{\n\s\s\s\sstringPtr->uallocated\s=\n\s\s\s\s\s\s\s\s\s(\s(\snumChars\s+\sappendNumChars\s)\s*\ssizeof\s(\sTcl_UniChar\s)\s)\s\n+\s\s1024\s;\n\s\s\s\stmpString\s=\s\s(\sString\s*\s)\s(\s(\s(\sstringPtr\s->\suallocated\s)\s>\s2147483647\s-\s(\ssizeof\s(\sString\s)\s-\ssizeof\s(\sTcl_UniChar\s)\s+\s(\s0\s)\s)\s)\s?\s(\sTcl_Panic\s(\s"unable\sto\salloc\s%u\sbytes"\s,\s(\ssizeof\s(\sString\s)\s-\ssizeof\s(\sTcl_UniChar\s)\s+\s(\sstringPtr\s->\suallocated\s)\s)\s)\s,\s(\schar\s*\s)\s0\s)\s:\sTcl_Realloc\s(\s(\schar\s*\s)\sstringPtr\s,\s(\sunsigned\s)\s(\ssizeof\s(\sString\s)\s-\ssizeof\s(\sTcl_UniChar\s)\s+\s(\s(\sstringPtr\s->\suallocated\s)\s?\s(\sstringPtr\s->\suallocated\s)\s:\ssizeof\s(\sTcl_UniChar\s)\s)\s)\s)\s);\n}\nstringPtr\s=\stmpString;\n\s(\sobjPtr\s)\s->\sinternalRep\s.\sotherValuePtr\s=\s(\svoid\s*\s)\s(\sstringPtr\s);\n\s\s\s\s}\n\nSo\swe\sattempt\sto\srealloc\s0\sbytes,\sthat\sdoes\snot\sfail\s(and\sis\slegal,\sshould\sfree\sthe\smemory)\sand\seven\sseem\sto\sreturn\ssome\spointer...\n\n--\sMatthias\sKraft\n
J login matzek
J mimetype text/plain
J username matzek
K 2494093fffffffffffffffffffffffffffffffff
U matzek
Z 12d0c7d4fad1e6a6bdae4af68ffe413a