rev |
line source |
al@19715
|
1 Patch by Guillem Jover <guillem@debian.org> for arj <= 3.10.22, to
|
al@19715
|
2 use a safe strcpy for overlapping strings, among others fixes a build
|
al@19715
|
3 problem with a mangled generated .c file by msgbind (thus FTBFS), and
|
al@19715
|
4 CRC errors at run-time. For further information, please have a look
|
al@19715
|
5 to http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=590354
|
al@19715
|
6
|
al@19715
|
7 ---
|
al@19715
|
8 arj.c | 2 +-
|
al@19715
|
9 arjdata.c | 9 +--------
|
al@19715
|
10 ea_mgr.c | 2 +-
|
al@19715
|
11 misc.h | 4 ++++
|
al@19715
|
12 msgbind.c | 2 +-
|
al@19715
|
13 packager.c | 2 +-
|
al@19715
|
14 6 files changed, 9 insertions(+), 12 deletions(-)
|
al@19715
|
15
|
al@19715
|
16 --- a/arjdata.c
|
al@19715
|
17 +++ b/arjdata.c
|
al@19715
|
18 @@ -204,13 +204,6 @@ void date_fmt(char *dest)
|
al@19715
|
19 #endif
|
al@19715
|
20 }
|
al@19715
|
21
|
al@19715
|
22 -/* A safe strcpy() */
|
al@19715
|
23 -
|
al@19715
|
24 -static void safe_strcpy(char *dest, char *src)
|
al@19715
|
25 -{
|
al@19715
|
26 - memmove(dest, src, strlen(src)+1);
|
al@19715
|
27 -}
|
al@19715
|
28 -
|
al@19715
|
29 /* Context substitution routine */
|
al@19715
|
30
|
al@19715
|
31 char *expand_tags(char *str, int limit)
|
al@19715
|
32 @@ -232,7 +225,7 @@ char *expand_tags(char *str, int limit)
|
al@19715
|
33 {
|
al@19715
|
34 if(*(p+1)==TAG_CHAR)
|
al@19715
|
35 {
|
al@19715
|
36 - strcpy(p, p+1);
|
al@19715
|
37 + safe_strcpy(p, p+1);
|
al@19715
|
38 p++;
|
al@19715
|
39 }
|
al@19715
|
40 else if(*(p+1)==TAG_SPECIAL_BEGIN&&(et=strchr(p+3, TAG_SPECIAL_END))!=NULL)
|
al@19715
|
41 --- a/arj.c
|
al@19715
|
42 +++ b/arj.c
|
al@19715
|
43 @@ -1169,7 +1169,7 @@ int main(int argc, char *argv[])
|
al@19715
|
44 if(strlen(tmp_ptr)<=121)
|
al@19715
|
45 tmp_ptr[0]='\0';
|
al@19715
|
46 else if(tmp_ptr[120]==' ')
|
al@19715
|
47 - strcpy(tmp_ptr, tmp_ptr+121);
|
al@19715
|
48 + safe_strcpy(tmp_ptr, tmp_ptr+121);
|
al@19715
|
49 }
|
al@19715
|
50 if(cmd==ARJ_CMD_ORDER&&strpbrk(tmp_ptr, wildcard_pattern)!=NULL)
|
al@19715
|
51 error(M_ORDER_WILDCARD);
|
al@19715
|
52 --- a/ea_mgr.c
|
al@19715
|
53 +++ b/ea_mgr.c
|
al@19715
|
54 @@ -696,7 +696,7 @@ int resolve_longname(char *dest, char *n
|
al@19715
|
55 tmp_name[st_len]='\0';
|
al@19715
|
56 if(tmp_name[0]==0xFD&&tmp_name[1]==0xFF)
|
al@19715
|
57 {
|
al@19715
|
58 - strcpy(tmp_name, (char *)tmp_name+4);
|
al@19715
|
59 + safe_strcpy(tmp_name, (char *)tmp_name+4);
|
al@19715
|
60 st_len-=4;
|
al@19715
|
61 }
|
al@19715
|
62 if(st_len==0||st_len+entry>=FILENAME_MAX)
|
al@19715
|
63 --- a/msgbind.c
|
al@19715
|
64 +++ b/msgbind.c
|
al@19715
|
65 @@ -578,7 +578,7 @@ int main(int argc, char **argv)
|
al@19715
|
66 }
|
al@19715
|
67 strcat(pool[tpool].data, msgname);
|
al@19715
|
68 strcat(pool[tpool].data, ", ");
|
al@19715
|
69 - strcpy(msg_buffer, msg_buffer+1);
|
al@19715
|
70 + safe_strcpy(msg_buffer, msg_buffer+1);
|
al@19715
|
71 buf_len=strlen(msg_buffer);
|
al@19715
|
72 msg_buffer[--buf_len]='\0';
|
al@19715
|
73 patch_string(msg_buffer);
|
al@19715
|
74 --- a/packager.c
|
al@19715
|
75 +++ b/packager.c
|
al@19715
|
76 @@ -347,7 +347,7 @@ int main(int argc, char **argv)
|
al@19715
|
77 expand_tags(buf, sizeof(buf)-1);
|
al@19715
|
78 if((p=strchr(buf, '.'))!=NULL)
|
al@19715
|
79 {
|
al@19715
|
80 - strcpy(p, p+1);
|
al@19715
|
81 + safe_strcpy(p, p+1);
|
al@19715
|
82 if((p=strchr(buf, '.'))!=NULL)
|
al@19715
|
83 *p='\0';
|
al@19715
|
84 }
|
al@19715
|
85 --- a/misc.h
|
al@19715
|
86 +++ b/misc.h
|
al@19715
|
87 @@ -11,6 +11,10 @@
|
al@19715
|
88 #include "arjtypes.h"
|
al@19715
|
89 #include "filelist.h"
|
al@19715
|
90
|
al@19715
|
91 +/* A safe strcpy() */
|
al@19715
|
92 +
|
al@19715
|
93 +#define safe_strcpy(dest, src) memmove(dest, src, strlen(src)+1);
|
al@19715
|
94 +
|
al@19715
|
95 /* ASCIIZ string copy macro */
|
al@19715
|
96
|
al@19715
|
97 #define strcpyn(dest, src, n) \
|