Index: /trunk/include/cf_codec.h
===================================================================
--- /trunk/include/cf_codec.h	(revision 95)
+++ /trunk/include/cf_codec.h	(revision 96)
@@ -25,5 +25,6 @@
 CF_EXPORT int
 CF_Codec_Hex_Decode			(const char		* hex,
-							 unsigned char	* bin);
+							 unsigned char	* bin,
+							 size_t			* len);
 
 CF_EXPORT int
@@ -34,5 +35,6 @@
 CF_EXPORT int
 CF_Codec_Base64_Decode		(const char		* base64,
-							 unsigned char	* bin);
+							 unsigned char	* bin,
+							 size_t			* len);
 
 #ifdef __cplusplus
Index: /trunk/src/cf_codec.c
===================================================================
--- /trunk/src/cf_codec.c	(revision 95)
+++ /trunk/src/cf_codec.c	(revision 96)
@@ -73,5 +73,5 @@
  *
  * @param bin	바이너리 데이터
- * @param len	바이너리 데이터 길이
+ * @param len	바이너리 데이터의 길이
  * @param hex	16진수 문자열을 저장할 주소
  *
@@ -114,4 +114,5 @@
  * @param hex	16진수 문자열
  * @param bin	바이너리 데이터를 저장할 주소
+ * @param len	바이너리 데이터의 길이를 저장할 주소
  *
  * @remark
@@ -120,9 +121,10 @@
 int
 CF_Codec_Hex_Decode (const char		* hex,
-					 unsigned char	* bin)
-{
-	size_t	length = strlen (hex);	/* absolutely even-number */
+					 unsigned char	* bin,
+					 size_t			* len)
+{
+	size_t	length = 0;	/* absolutely even-number */
 	size_t	iter = 0;
-	int		binlen = (int)length / 2;
+	size_t	binlen = 0;
 
 	const char		* ptr = hex;
@@ -133,6 +135,16 @@
 	ASSERT_ARGS (hex == NULL);
 	ASSERT_ARGS (bin == NULL);
-
-	for (iter = 0 ; iter < binlen ; iter++)
+	ASSERT_ARGS (len == NULL);
+
+	*len = 0;
+
+	for ( ; g_ascii_HexDecode[(int)*ptr] && *ptr ; ptr++, length++);
+
+	if (*ptr)
+		return CF_ERROR_CODEC_NOT_HEXSTRING;
+
+	binlen = length / 2;
+
+	for (iter = 0, ptr = hex ; *ptr ; iter++)
 	{
 		val = 0;	/* init/re-init docoding-buffer */
@@ -145,9 +157,6 @@
 		asciiHex = g_ascii_HexDecode[(int)buf];		\
 													\
-		if (buf)									\
-			val |=	(unsigned char)					\
-					(buf - asciiHex + (asciiHex == '0' ? 0 : 10));	\
-		else										\
-			return CF_ERROR_CODEC_NOT_HEXSTRING;	\
+		val |=	(unsigned char)						\
+				(buf - asciiHex + (asciiHex == '0' ? 0 : 10));	\
 		} while (0)
 
@@ -159,5 +168,7 @@
 	}
 
-	return binlen;
+	* len = binlen;
+
+	return CF_OK;
 }
 
@@ -232,4 +243,5 @@
  * @param base64	base64 문자열
  * @param bin		바이너리 데이터를 저장할 주소
+ * @param len		바이너리 데이터의 길이를 저장할 주소
  *
  * @remark
@@ -238,5 +250,6 @@
 int
 CF_Codec_Base64_Decode (const char		* base64,
-						unsigned char	* bin)
+						unsigned char	* bin,
+						size_t			* len)
 {
 	const char		* src = base64;
@@ -247,4 +260,7 @@
 	ASSERT_ARGS (src == NULL);
 	ASSERT_ARGS (dst == NULL);
+	ASSERT_ARGS (len == NULL);
+
+	*len = 0;
 
 	while (g_ascii_Base64Decode[(int)*src] < BASE64_PADDING_CHAR_INDEX) src++;
Index: /trunk/test/codec.c
===================================================================
--- /trunk/test/codec.c	(revision 95)
+++ /trunk/test/codec.c	(revision 96)
@@ -14,5 +14,5 @@
 	char encode[512] = {0x00,};
 	unsigned char bin[512] = {0x00,};
-	int length = 0;
+	size_t length = 0;
 
 	/* hex */
@@ -25,9 +25,9 @@
 
 	CF_DEBUG_PRINT (stderr, "= Convert hex to binary =\n");
-	length = CF_Codec_Hex_Decode (encode, bin);
-	if (length < 0) {
+	if (CF_Codec_Hex_Decode (encode, bin, &length) < 0) {
 		// error
 	}
-	CF_DEBUG_PRINT_BIN (stderr, bin, (size_t)length, "bin    : %s\n", bin);
+	else
+		CF_DEBUG_PRINT_BIN (stderr, bin, length, "bin    : %s\n", bin);
 
 	memset (bin   , 0x00, sizeof (bin));
@@ -43,9 +43,9 @@
 
 	CF_DEBUG_PRINT (stderr, "= Convert base64 to binary =\n");
-	length = CF_Codec_Base64_Decode (encode, bin);
-	if (length < 0) {
+	if (CF_Codec_Base64_Decode (encode, bin, &length) < 0) {
 		// error
 	}
-	CF_DEBUG_PRINT_BIN (stderr, bin, (size_t)length, "bin    : %s\n", bin);
+	else
+		CF_DEBUG_PRINT_BIN (stderr, bin, length, "bin    : %s\n", bin);
 
 	return 0;
Index: /trunk/test/test.c
===================================================================
--- /trunk/test/test.c	(revision 95)
+++ /trunk/test/test.c	(revision 96)
@@ -389,5 +389,5 @@
 	char encode[512] = {0x00,};
 	unsigned char bin[512] = {0x00,};
-	int length = 0;
+	size_t length = 0;
 
 	/* hex */
@@ -400,9 +400,9 @@
 
 	CF_DEBUG_PRINT (stderr, "= Convert hex to binary =\n");
-	length = CF_Codec_Hex_Decode (encode, bin);
-	if (length < 0) {
-		// error
-	}
-	CF_DEBUG_PRINT_BIN (stderr, bin, (size_t)length, "bin    : %s\n", bin);
+	if (CF_Codec_Hex_Decode (encode, bin, &length) < 0) {
+		// error
+	}
+	else
+		CF_DEBUG_PRINT_BIN (stderr, bin, length, "bin    : %s\n", bin);
 
 	memset (bin   , 0x00, sizeof (bin));
@@ -418,8 +418,8 @@
 
 	CF_DEBUG_PRINT (stderr, "= Convert base64 to binary =\n");
-	length = CF_Codec_Base64_Decode (encode, bin);
-	if (length < 0) {
-		// error
-	}
-	CF_DEBUG_PRINT_BIN (stderr, bin, (size_t)length, "bin    : %s\n", bin);
-}
+	if (CF_Codec_Base64_Decode (encode, bin, &length) < 0) {
+		// error
+	}
+	else
+		CF_DEBUG_PRINT_BIN (stderr, bin, length, "bin    : %s\n", bin);
+}
