This commit is contained in:
King_DuckZ 2020-05-05 20:22:56 +02:00
parent 87f99873d9
commit f6f5938fe7
7 changed files with 71 additions and 473 deletions

View file

@ -104,25 +104,6 @@ static BOOL IsBigEndian(void)
return TRUE; return TRUE;
} }
// ¾ÈÀüÇÑ strcpy
static void safe_strcpy(char* dst, const char* src, size_t dst_size)
{
#ifdef _WIN32
lstrcpynA(dst, src, dst_size);
#else
strlcpy(dst, src, dst_size);
#endif
}
static void safe_strcat(char* dst, const char* src, size_t dst_size)
{
#ifdef _WIN32
StringCchCatExA(dst, dst_size, src, NULL, NULL, STRSAFE_FILL_BEHIND_NULL);
//lstrcatA(dst, src); // not safe!!
#else
strlcat(dst, src, dst_size);
#endif
}
#ifdef _WIN32 #ifdef _WIN32
# define safe_sprintf StringCbPrintfA # define safe_sprintf StringCbPrintfA
@ -1928,3 +1909,50 @@ void CUnAlz::SetDestCodepage(const char* szToCodepage)
#endif #endif
////////////////////////////////////////////////////////////////////////////////////////////////////
/// 문자열 처리 함수들
/// @param l
/// @param c
/// @return
/// @date 2007-02
////////////////////////////////////////////////////////////////////////////////////////////////////
unsigned int CUnAlz::_strlcpy (char *dest, const char *src, unsigned int size)
{
register unsigned int i = 0;
if (size > 0) {
size--;
for (i=0; size > 0 && src[i] != '\0'; ++i, size--)
dest[i] = src[i];
dest[i] = '\0';
}
while (src[i++]);
return i;
}
unsigned int CUnAlz::_strlcat (char *dest, const char *src, unsigned int size)
{
register char *d = dest;
for (; size > 0 && *d != '\0'; size--, d++);
return (d - dest) + _strlcpy(d, src, size);
}
// 안전한 strcpy
void CUnAlz::safe_strcpy(char* dst, const char* src, size_t dst_size)
{
#ifdef _WIN32
lstrcpynA(dst, src, dst_size);
#else
_strlcpy(dst, src, dst_size);
#endif
}
void CUnAlz::safe_strcat(char* dst, const char* src, size_t dst_size)
{
#ifdef _WIN32
StringCchCatExA(dst, dst_size, src, NULL, NULL, STRSAFE_FILL_BEHIND_NULL);
//lstrcatA(dst, src); // not safe!!
#else
_strlcat(dst, src, dst_size);
#endif
}

12
UnAlz.h
View file

@ -107,6 +107,8 @@
2006/04/23 - 2006/04/23 -
2006/12/31 - strcpy/strcat/sprintf (by liam.joo@gmail) 2006/12/31 - strcpy/strcat/sprintf (by liam.joo@gmail)
- unalz 0.60 - unalz 0.60
2007/02/10 - strlcpy, strlcat
- unalz 0.61
: :
- alz (deflate/ bzip2/raw) - alz (deflate/ bzip2/raw)
@ -210,8 +212,8 @@ namespace UNALZ
# pragma pack(1) # pragma pack(1)
#endif #endif
static const char UNALZ_VERSION[] = "CUnAlz0.60"; static const char UNALZ_VERSION[] = "CUnAlz0.61";
static const char UNALZ_COPYRIGHT[] = "Copyright(C) 2004-2006 by hardkoder@gmail ( http://www.kipple.pe.kr ) "; static const char UNALZ_COPYRIGHT[] = "Copyright(C) 2004-2007 by hardkoder@gmail ( http://www.kipple.pe.kr ) ";
enum {ENCR_HEADER_LEN=12}; // xf86 enum {ENCR_HEADER_LEN=12}; // xf86
// 맨 파일 앞.. // 맨 파일 앞..
@ -483,6 +485,12 @@ public :
static const char* GetCopyright() { return UNALZ_COPYRIGHT; } static const char* GetCopyright() { return UNALZ_COPYRIGHT; }
BOOL IsHalted() { return m_bHalt; } // by xf86 BOOL IsHalted() { return m_bHalt; } // by xf86
public :
static void safe_strcpy(char* dst, const char* src, size_t dst_size);
static void safe_strcat(char* dst, const char* src, size_t dst_size);
static unsigned int _strlcpy (char *dest, const char *src, unsigned int size);
static unsigned int _strlcat (char *dest, const char *src, unsigned int size);
private : private :
SIGNATURE ReadSignature(); SIGNATURE ReadSignature();
BOOL ReadAlzFileHeader(); BOOL ReadAlzFileHeader();

View file

@ -2,10 +2,6 @@
#include <time.h> #include <time.h>
#include "UnAlzUtils.h" #include "UnAlzUtils.h"
#ifdef _WIN32 // safe string ó¸®
# include "strsafe.h"
#endif
#ifdef _WIN32 #ifdef _WIN32
# define I64FORM(x) "%"#x"I64d" # define I64FORM(x) "%"#x"I64d"
# define U64FORM(x) "%"#x"I64u" # define U64FORM(x) "%"#x"I64u"
@ -29,15 +25,6 @@ time_t dosTime2TimeT(UINT32 dostime) // from INFO-ZIP src
return mktime(&t); return mktime(&t);
} }
static void safe_strcat(char* dst, const char* src, size_t dst_size)
{
#ifdef _WIN32
StringCchCatExA(dst, dst_size, src, NULL, NULL, STRSAFE_FILL_BEHIND_NULL);
//lstrcatA(dst, src); // not safe!!
#else
strlcat(dst, src, dst_size);
#endif
}
//////////////////////////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////////////////////////////
/// fileAttribute 를 스트링으로 바꿔준다. /// fileAttribute 를 스트링으로 바꿔준다.
@ -51,24 +38,24 @@ void FileAttr2Str(char szAttr[LEN_ATTR], BYTE fileAttribute)
szAttr[0] = 0; szAttr[0] = 0;
if(fileAttribute&ALZ_FILEATTR_FILE) if(fileAttribute&ALZ_FILEATTR_FILE)
safe_strcat(szAttr, "A", LEN_ATTR); CUnAlz::safe_strcat(szAttr, "A", LEN_ATTR);
else else
safe_strcat(szAttr, "_", LEN_ATTR); CUnAlz::safe_strcat(szAttr, "_", LEN_ATTR);
if(fileAttribute&ALZ_FILEATTR_DIRECTORY) if(fileAttribute&ALZ_FILEATTR_DIRECTORY)
safe_strcat(szAttr, "D", LEN_ATTR); CUnAlz::safe_strcat(szAttr, "D", LEN_ATTR);
else else
safe_strcat(szAttr, "_", LEN_ATTR); CUnAlz::safe_strcat(szAttr, "_", LEN_ATTR);
if(fileAttribute&ALZ_FILEATTR_READONLY) if(fileAttribute&ALZ_FILEATTR_READONLY)
safe_strcat(szAttr, "R", LEN_ATTR); CUnAlz::safe_strcat(szAttr, "R", LEN_ATTR);
else else
safe_strcat(szAttr, "_", LEN_ATTR); CUnAlz::safe_strcat(szAttr, "_", LEN_ATTR);
if(fileAttribute&ALZ_FILEATTR_HIDDEN) if(fileAttribute&ALZ_FILEATTR_HIDDEN)
safe_strcat(szAttr, "H", LEN_ATTR); CUnAlz::safe_strcat(szAttr, "H", LEN_ATTR);
else else
safe_strcat(szAttr, "_", LEN_ATTR); CUnAlz::safe_strcat(szAttr, "_", LEN_ATTR);
} }

View file

@ -29,8 +29,9 @@ void Copyright()
// printf("unalz v0.53 (2005/10/15) \n"); // printf("unalz v0.53 (2005/10/15) \n");
// printf("unalz v0.54 (2005/11/21) \n"); // printf("unalz v0.54 (2005/11/21) \n");
// printf("unalz v0.55 (2006/03/10) \n"); // printf("unalz v0.55 (2006/03/10) \n");
printf("unalz v0.60 (2006/12/31) \n"); // printf("unalz v0.60 (2006/12/31) \n");
printf("Copyright(C) 2004-2006 by hardkoder@gmail (http://www.kipple.pe.kr) \n"); printf("unalz v0.61 (2007/02/10) \n");
printf("Copyright(C) 2004-2007 by hardkoder@gmail (http://www.kipple.pe.kr) \n");
} }
@ -93,7 +94,7 @@ void UnAlzCallback(const char* szFileName, INT64 nCurrent, INT64 nRange, void* p
INT64 percent; INT64 percent;
// 파일명 출력.. // 파일명 출력..
if(szMessage) if(szFileName)
{ {
printf("\n"); printf("\n");
#ifdef _WIN32 #ifdef _WIN32

View file

@ -1,8 +1,8 @@
unalz v0.60 unalz v0.61
Copyright(C) 2004-2006 by hardkoder (http://www.kipple.pe.kr) Copyright(C) 2004-2007 by hardkoder (http://www.kipple.pe.kr)
- 최초 작성일 : v0.20 - 2004/10/22 - 최초 작성일 : v0.20 - 2004/10/22

View file

@ -1,29 +0,0 @@
Microsoft Visual Studio Solution File, Format Version 8.00
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "unalz", "unalz.vcproj", "{E92968E8-DF95-411B-80E2-23F17B3DDFF8}"
ProjectSection(ProjectDependencies) = postProject
EndProjectSection
EndProject
Global
GlobalSection(SourceCodeControl) = preSolution
SccNumberOfProjects = 1
SccProjectUniqueName0 = unalz.vcproj
SccProjectName0 = \u0022$/Home/unalz\u0022,\u0020VXBAAAAA
SccLocalPath0 = .
SccProvider0 = MSSCCI:Microsoft\u0020Visual\u0020SourceSafe
CanCheckoutShared = false
EndGlobalSection
GlobalSection(SolutionConfiguration) = preSolution
Debug = Debug
Release = Release
EndGlobalSection
GlobalSection(ProjectConfiguration) = postSolution
{E92968E8-DF95-411B-80E2-23F17B3DDFF8}.Debug.ActiveCfg = Debug|Win32
{E92968E8-DF95-411B-80E2-23F17B3DDFF8}.Debug.Build.0 = Debug|Win32
{E92968E8-DF95-411B-80E2-23F17B3DDFF8}.Release.ActiveCfg = Release|Win32
{E92968E8-DF95-411B-80E2-23F17B3DDFF8}.Release.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
EndGlobalSection
GlobalSection(ExtensibilityAddIns) = postSolution
EndGlobalSection
EndGlobal

View file

@ -1,397 +0,0 @@
<?xml version="1.0" encoding="ks_c_5601-1987"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="7.10"
Name="unalz"
SccProjectName="&quot;$/Home/unalz&quot;, VXBAAAAA"
SccAuxPath=""
SccLocalPath="."
SccProvider="MSSCCI:Microsoft Visual SourceSafe">
<Platforms>
<Platform
Name="Win32"/>
</Platforms>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory=".\Debug"
IntermediateDirectory=".\Debug"
ConfigurationType="1"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="FALSE"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
BasicRuntimeChecks="3"
RuntimeLibrary="5"
UsePrecompiledHeader="2"
PrecompiledHeaderFile=".\Debug/unalz.pch"
AssemblerListingLocation=".\Debug/"
ObjectFile=".\Debug/"
ProgramDataBaseFileName=".\Debug/"
WarningLevel="3"
SuppressStartupBanner="TRUE"
DebugInformationFormat="4"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
OutputFile="bin/unalz_d.exe"
LinkIncremental="1"
SuppressStartupBanner="TRUE"
GenerateDebugInformation="TRUE"
ProgramDatabaseFile=".\Debug/unalz_d.pdb"
SubSystem="1"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"
TypeLibraryName=".\Debug/unalz.tlb"
HeaderFileName=""/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="_DEBUG"
Culture="1042"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory=".\Release"
IntermediateDirectory=".\Release"
ConfigurationType="1"
UseOfMFC="0"
ATLMinimizesCRunTimeLibraryUsage="FALSE"
CharacterSet="2">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
InlineFunctionExpansion="1"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
StringPooling="TRUE"
RuntimeLibrary="4"
EnableFunctionLevelLinking="TRUE"
UsePrecompiledHeader="2"
PrecompiledHeaderFile=".\Release/unalz.pch"
AssemblerListingLocation=".\Release/"
ObjectFile=".\Release/"
ProgramDataBaseFileName=".\Release/"
WarningLevel="3"
SuppressStartupBanner="TRUE"/>
<Tool
Name="VCCustomBuildTool"/>
<Tool
Name="VCLinkerTool"
OutputFile="bin/unalz.exe"
LinkIncremental="1"
SuppressStartupBanner="TRUE"
ProgramDatabaseFile=".\Release/unalz.pdb"
SubSystem="1"
TargetMachine="1"/>
<Tool
Name="VCMIDLTool"
TypeLibraryName=".\Release/unalz.tlb"
HeaderFileName=""/>
<Tool
Name="VCPostBuildEventTool"/>
<Tool
Name="VCPreBuildEventTool"/>
<Tool
Name="VCPreLinkEventTool"/>
<Tool
Name="VCResourceCompilerTool"
PreprocessorDefinitions="NDEBUG"
Culture="1042"/>
<Tool
Name="VCWebServiceProxyGeneratorTool"/>
<Tool
Name="VCXMLDataGeneratorTool"/>
<Tool
Name="VCWebDeploymentTool"/>
<Tool
Name="VCManagedWrapperGeneratorTool"/>
<Tool
Name="VCAuxiliaryManagedWrapperGeneratorTool"/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="main"
Filter="">
<File
RelativePath="main.cpp">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions=""
BasicRuntimeChecks="3"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
PreprocessorDefinitions=""/>
</FileConfiguration>
</File>
</Filter>
<Filter
Name="bzip2"
Filter="">
<File
RelativePath="bzip2\blocksort.c">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions=""
BasicRuntimeChecks="3"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
PreprocessorDefinitions=""/>
</FileConfiguration>
</File>
<File
RelativePath="bzip2\bzlib.h">
</File>
<File
RelativePath="bzip2\bzlib_private.h">
</File>
<File
RelativePath="bzip2\compress.c">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions=""
BasicRuntimeChecks="3"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
PreprocessorDefinitions=""/>
</FileConfiguration>
</File>
<File
RelativePath="bzip2\crctable.c">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions=""
BasicRuntimeChecks="3"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
PreprocessorDefinitions=""/>
</FileConfiguration>
</File>
<File
RelativePath="bzip2\huffman.c">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions=""
BasicRuntimeChecks="3"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
PreprocessorDefinitions=""/>
</FileConfiguration>
</File>
<File
RelativePath="bzip2\randtable.c">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions=""
BasicRuntimeChecks="3"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
PreprocessorDefinitions=""/>
</FileConfiguration>
</File>
</Filter>
<Filter
Name="zlib"
Filter="">
<File
RelativePath=".\zlib\adler32.c">
</File>
<File
RelativePath=".\zlib\crc32.c">
</File>
<File
RelativePath=".\zlib\crc32.h">
</File>
<File
RelativePath=".\zlib\infback.c">
</File>
<File
RelativePath=".\zlib\inffast.c">
</File>
<File
RelativePath=".\zlib\inffast.h">
</File>
<File
RelativePath=".\zlib\inffixed.h">
</File>
<File
RelativePath=".\zlib\inflate.c">
</File>
<File
RelativePath=".\zlib\inflate.h">
</File>
<File
RelativePath=".\zlib\inftrees.c">
</File>
<File
RelativePath=".\zlib\inftrees.h">
</File>
<File
RelativePath=".\zlib\zconf.h">
</File>
<File
RelativePath=".\zlib\zconf.in.h">
</File>
<File
RelativePath=".\zlib\zlib.h">
</File>
<File
RelativePath=".\zlib\zutil.c">
</File>
<File
RelativePath=".\zlib\zutil.h">
</File>
</Filter>
<Filter
Name="unalz"
Filter="">
<File
RelativePath="UnAlz.cpp">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions=""
BasicRuntimeChecks="3"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
PreprocessorDefinitions=""/>
</FileConfiguration>
</File>
<File
RelativePath="UnAlz.h">
</File>
<File
RelativePath="UnAlzBz2decompress.c">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions=""
BasicRuntimeChecks="3"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
PreprocessorDefinitions=""/>
</FileConfiguration>
</File>
<File
RelativePath="UnAlzBzip2.cpp">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions=""
BasicRuntimeChecks="3"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
PreprocessorDefinitions=""/>
</FileConfiguration>
</File>
<File
RelativePath="UnAlzbzlib.c">
<FileConfiguration
Name="Debug|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
PreprocessorDefinitions=""
BasicRuntimeChecks="3"/>
</FileConfiguration>
<FileConfiguration
Name="Release|Win32">
<Tool
Name="VCCLCompilerTool"
Optimization="2"
PreprocessorDefinitions=""/>
</FileConfiguration>
</File>
<File
RelativePath=".\UnAlzUtils.cpp">
</File>
<File
RelativePath=".\UnAlzUtils.h">
</File>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>