src/ip.h 里需要做一些修改,否则编译会有错误,发生重复定义;
提示open with O_CREAT in second argument needs 3 arguments时,给open函数加上第三个参数0777;
aes_setkey函数中,使用key变量前,先对其置零;
aes.h中,将typedef unsigned long u4byte;改成typedef unsigned int u4byte; 在64位的系统下,GCC会认为unsigned long是8个字节,而tfn2k把它当4个字节使用,从而导致在aes_setkey函数中误用。 最终导致的问题就是,在使用tfn时,一直提示“Sorry, passwords do not match.” , 挺坑爹的, 原来tfn2k不兼容64位。
所有改动,见下面的patch。
---
aes.c | 1 +
aes.h | 2 +-
disc.c | 2 +-
ip.h | 2 ++
mkpass.c | 2 +-
5 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/aes.c b/aes.c
index d918791..5186f16 100644
--- a/aes.c
+++ b/aes.c
@@ -9,6 +9,7 @@ aes_setkey (char *password)
{
u4byte keylen = strlen (password) * 8;
u4byte key[strlen (password) / 4];
+ memset(key, 0, sizeof(key));
memcpy (key, password, strlen (password));
return (set_key (key, keylen));
}
diff --git a/aes.h b/aes.h
index ea65f17..cba4409 100644
--- a/aes.h
+++ b/aes.h
@@ -12,7 +12,7 @@ void base64_out (char *, unsigned char *, int);
typedef unsigned char u1byte; /* an 8 bit unsigned character type */
typedef unsigned short u2byte; /* a 16 bit unsigned integer type */
-typedef unsigned long u4byte; /* a 32 bit unsigned integer type */
+typedef unsigned int u4byte; /* a 32 bit unsigned integer type */
typedef signed char s1byte; /* an 8 bit signed character type */
typedef signed short s2byte; /* a 16 bit signed integer type */
typedef signed long s4byte; /* a 32 bit signed integer type */
diff --git a/disc.c b/disc.c
index 3303ac6..0ec6cf6 100644
--- a/disc.c
+++ b/disc.c
@@ -27,7 +27,7 @@ main (void)
{
case 'y':
case 'Y':
- close (open ("agreed", O_WRONLY | O_CREAT | O_TRUNC));
+ close (open ("agreed", O_WRONLY | O_CREAT | O_TRUNC, 0777));
break;
default:
system ("/bin/rm -f ./*");
diff --git a/ip.h b/ip.h
index 2c1c39d..62594dc 100644
--- a/ip.h
+++ b/ip.h
@@ -121,10 +121,12 @@ struct icmp
};
#ifndef in_addr
+/*
struct in_addr
{
unsigned long int s_addr;
};
+*/
#endif
char *inet_ntoa (struct in_addr);
diff --git a/mkpass.c b/mkpass.c
index d32e92d..84f16c3 100644
--- a/mkpass.c
+++ b/mkpass.c
@@ -84,7 +84,7 @@ dufus:
goto dufus;
for (i = 0; i <= strlen (p); i++)
c[i] = p[i];
- fd = open ("pass.c", O_WRONLY | O_TRUNC | O_CREAT);
+ fd = open ("pass.c", O_WRONLY | O_TRUNC | O_CREAT, 0777);
write (fd, header, strlen (header));
for (i = 0; i < 31; i++)
{
--