diff --git a/codemaker/source/codemaker/global.cxx b/codemaker/source/codemaker/global.cxx index 0a9cf41b1a21..62e6df34a862 100644 --- a/codemaker/source/codemaker/global.cxx +++ b/codemaker/source/codemaker/global.cxx @@ -2,9 +2,9 @@ * * $RCSfile: global.cxx,v $ * - * $Revision: 1.16 $ + * $Revision: 1.17 $ * - * last change: $Author: hr $ $Date: 2002-08-20 13:51:40 $ + * last change: $Author: hr $ $Date: 2003-03-19 15:53:41 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -111,7 +111,7 @@ OString makeTempName(sal_Char* prefix) OUString uPattern; sal_Char* pPrefix = "cmk_"; - sal_Char tmpPattern[512]; + sal_Char tmpPattern[512] = ""; sal_Char *pTmpName = NULL; if (prefix) @@ -122,34 +122,48 @@ OString makeTempName(sal_Char* prefix) if ( osl_getEnvironment(uTEMP.pData, &uPattern.pData) != osl_Process_E_None ) { #if defined(SAL_W32) || defined(SAL_OS2) - strcpy(tmpPattern, "."); + OSL_ASSERT( sizeof(tmpPattern) > RTL_CONSTASCII_LENGTH( "." ) ); + strncpy(tmpPattern, ".", sizeof(tmpPattern)-1); #else - strcpy(tmpPattern, "/tmp"); + OSL_ASSERT( sizeof(tmpPattern) > RTL_CONSTASCII_LENGTH( "/tmp" ) ); + strncpy(tmpPattern, "/tmp", sizeof(tmpPattern)-1); #endif } } if (uPattern.getLength()) { - strcpy(tmpPattern, OUStringToOString(uPattern, RTL_TEXTENCODING_UTF8).getStr()); + OString aOStr( OUStringToOString(uPattern, RTL_TEXTENCODING_UTF8) ); + OSL_ASSERT( sizeof(tmpPattern) > aOStr.getLength() ); + strncpy(tmpPattern, aOStr.getStr(), sizeof(tmpPattern)-1); } #ifdef SAL_W32 - strcat(tmpPattern, "\\"); - strcat(tmpPattern, pPrefix); - strcat(tmpPattern, "XXXXXX"); + OSL_ASSERT( sizeof(tmpPattern) > ( strlen(tmpPattern) + + RTL_CONSTASCII_LENGTH("\\") + + strlen(pPrefix) + + RTL_CONSTASCII_LENGTH("XXXXXX") ) ); + strncat(tmpPattern, "\\", sizeof(tmpPattern)-1-strlen(tmpPattern)); + strncat(tmpPattern, pPrefix, sizeof(tmpPattern)-1-strlen(tmpPattern)); + strncat(tmpPattern, "XXXXXX", sizeof(tmpPattern)-1-strlen(tmpPattern)); pTmpName = mktemp(tmpPattern); #endif #ifdef SAL_OS2 - strcpy(tmpPattern, tempnam(NULL, prefix); + char* tmpname = tempnam(NULL, prefix); + OSL_ASSERT( sizeof(tmpPattern) > strlen(tmpname) ); + strncpy(tmpPattern, tmpname, sizeof(tmpPattern)-1); pTmpName = tmpPattern; #endif #ifdef SAL_UNX - strcat(tmpPattern, "/"); - strcat(tmpPattern, pPrefix); - strcat(tmpPattern, "XXXXXX"); + OSL_ASSERT( sizeof(tmpPattern) > ( strlen(tmpPattern) + + RTL_CONSTASCII_LENGTH("/") + + strlen(pPrefix) + + RTL_CONSTASCII_LENGTH("XXXXXX") ) ); + strncat(tmpPattern, "/", sizeof(tmpPattern)-1-strlen(tmpPattern)); + strncat(tmpPattern, pPrefix, sizeof(tmpPattern)-1-strlen(tmpPattern)); + strncat(tmpPattern, "XXXXXX", sizeof(tmpPattern)-1-strlen(tmpPattern)); #if defined(FREEBSD) || defined(MACOSX) pTmpName = mkstemp(tmpPattern); #else diff --git a/codemaker/source/cppumaker/cpputype.cxx b/codemaker/source/cppumaker/cpputype.cxx index 084be04eaad0..5a5e41fdb704 100644 --- a/codemaker/source/cppumaker/cpputype.cxx +++ b/codemaker/source/cppumaker/cpputype.cxx @@ -2,9 +2,9 @@ * * $RCSfile: cpputype.cxx,v $ * - * $Revision: 1.20 $ + * $Revision: 1.21 $ * - * last change: $Author: dbo $ $Date: 2002-07-31 12:46:38 $ + * last change: $Author: hr $ $Date: 2003-03-19 15:53:41 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -1412,7 +1412,7 @@ void CppuType::dumpConstantValue(FileStream& o, sal_uInt16 index) case RT_TYPE_BYTE: { char tmp[16]; - sprintf(tmp, "0x%x", (sal_Int8)constValue.m_value.aByte); + snprintf(tmp, sizeof(tmp), "0x%x", (sal_Int8)constValue.m_value.aByte); o << "(sal_Int8)" << tmp; } break; @@ -2024,7 +2024,7 @@ void InterfaceType::dumpCGetCppuType(FileStream& o) RTUik uik; m_reader.getUik(uik); sal_Char buffer[53]; - sprintf(buffer, "0x%.8x, 0x%.4x, 0x%.4x, 0x%.8x, 0x%.8x,\n", + snprintf(buffer, sizeof(buffer), "0x%.8x, 0x%.4x, 0x%.4x, 0x%.8x, 0x%.8x,\n", uik.m_Data1, uik.m_Data2, uik.m_Data3, uik.m_Data4, uik.m_Data5); o << buffer; diff --git a/codemaker/source/cunomaker/cunotype.cxx b/codemaker/source/cunomaker/cunotype.cxx index 59d7d1107fdc..b0220c3a9036 100644 --- a/codemaker/source/cunomaker/cunotype.cxx +++ b/codemaker/source/cunomaker/cunotype.cxx @@ -2,9 +2,9 @@ * * $RCSfile: cunotype.cxx,v $ * - * $Revision: 1.5 $ + * $Revision: 1.6 $ * - * last change: $Author: jsc $ $Date: 2002-06-18 17:23:49 $ + * last change: $Author: hr $ $Date: 2003-03-19 15:53:42 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -1455,7 +1455,7 @@ void CunoType::dumpConstantValue(FileStream& o, sal_uInt16 index) case RT_TYPE_BYTE: { char tmp[16]; - sprintf(tmp, "0x%x", (sal_Int8)constValue.m_value.aByte); + snprintf(tmp, sizeof(tmp), "0x%x", (sal_Int8)constValue.m_value.aByte); o << "(sal_Int8)" << tmp; } break; @@ -2060,7 +2060,7 @@ void InterfaceType::dumpCGetCunoType(FileStream& o) RTUik uik; m_reader.getUik(uik); sal_Char buffer[53]; - sprintf(buffer, "0x%.8x, 0x%.4x, 0x%.4x, 0x%.8x, 0x%.8x,\n", + snprintf(buffer, sizeof(buffer), "0x%.8x, 0x%.4x, 0x%.4x, 0x%.8x, 0x%.8x,\n", uik.m_Data1, uik.m_Data2, uik.m_Data3, uik.m_Data4, uik.m_Data5); o << buffer; diff --git a/codemaker/source/idlmaker/idltype.cxx b/codemaker/source/idlmaker/idltype.cxx index 432b765808c0..7406f74d0ea3 100644 --- a/codemaker/source/idlmaker/idltype.cxx +++ b/codemaker/source/idlmaker/idltype.cxx @@ -2,9 +2,9 @@ * * $RCSfile: idltype.cxx,v $ * - * $Revision: 1.4 $ + * $Revision: 1.5 $ * - * last change: $Author: jsc $ $Date: 2002-06-18 17:24:51 $ + * last change: $Author: hr $ $Date: 2003-03-19 15:53:45 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -701,7 +701,7 @@ void IdlType::dumpConstantValue(FileStream& o, sal_uInt16 index) case RT_TYPE_BYTE: { char tmp[16]; - sprintf(tmp, "0x%x", (sal_Int8)constValue.m_value.aByte); + snprintf(tmp, sizeof(tmp), "0x%x", (sal_Int8)constValue.m_value.aByte); o << tmp; } break; diff --git a/codemaker/source/javamaker/javatype.cxx b/codemaker/source/javamaker/javatype.cxx index ae98ec3e85cc..6ec70bd59430 100644 --- a/codemaker/source/javamaker/javatype.cxx +++ b/codemaker/source/javamaker/javatype.cxx @@ -2,9 +2,9 @@ * * $RCSfile: javatype.cxx,v $ * - * $Revision: 1.16 $ + * $Revision: 1.17 $ * - * last change: $Author: dbo $ $Date: 2002-07-31 12:46:45 $ + * last change: $Author: hr $ $Date: 2003-03-19 15:53:45 $ * * The Contents of this file are made available subject to the terms of * either of the following licenses @@ -373,11 +373,11 @@ void JavaType::dumpTypeInit(FileStream& o, const OString& name, const OString& t o << indent() << name << " = \"\";\n"; return; case BT_TYPE: - o << indent() << name << " = new com.sun.star.uno.Type();\n"; + o << indent() << name << " = com.sun.star.uno.Type.VOID;\n"; return; case BT_ANY: -// o << "new java.lang.Object()"; -// return; + o << indent() << name << " = com.sun.star.uno.Any.VOID;\n"; + return; case BT_BOOLEAN: case BT_CHAR: case BT_FLOAT: @@ -865,7 +865,7 @@ sal_Bool InterfaceType::dumpFile(FileStream& o) RTUik uik; m_reader.getUik(uik); sal_Char buffer[67]; - sprintf(buffer, "0x%.8x, (short)0x%.4x, (short)0x%.4x, 0x%.8x, 0x%.8x", + snprintf(buffer, sizeof(buffer), "0x%.8x, (short)0x%.4x, (short)0x%.4x, 0x%.8x, 0x%.8x", uik.m_Data1, uik.m_Data2, uik.m_Data3, uik.m_Data4, uik.m_Data5); o << buffer << " );\n\n"; */ @@ -1464,7 +1464,7 @@ sal_Bool StructureType::dumpFile(FileStream& o) o << " " << fieldName << ";\n"; } - o << "\n" << indent() << "//constructors\n"; + o << "\n" << indent() << "// constructors\n"; o << indent() << "public " << m_name << "()\n" << indent() << "{\n"; inc(); OString relType;