1 Patch by Guillem Jover <guillem@debian.org> for arj <= 3.10.22, to
2 use a safe strcpy for overlapping strings, among others fixes a build
3 problem with a mangled generated .c file by msgbind (thus FTBFS), and
4 CRC errors at run-time. For further information, please have a look
5 to http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=590354
9 arjdata.c | 9 +--------
14 6 files changed, 9 insertions(+), 12 deletions(-)
18 @@ -204,13 +204,6 @@ void date_fmt(char *dest)
22 -/* A safe strcpy() */
24 -static void safe_strcpy(char *dest, char *src)
26 - memmove(dest, src, strlen(src)+1);
29 /* Context substitution routine */
31 char *expand_tags(char *str, int limit)
32 @@ -232,7 +225,7 @@ char *expand_tags(char *str, int limit)
37 + safe_strcpy(p, p+1);
40 else if(*(p+1)==TAG_SPECIAL_BEGIN&&(et=strchr(p+3, TAG_SPECIAL_END))!=NULL)
43 @@ -1169,7 +1169,7 @@ int main(int argc, char *argv[])
44 if(strlen(tmp_ptr)<=121)
46 else if(tmp_ptr[120]==' ')
47 - strcpy(tmp_ptr, tmp_ptr+121);
48 + safe_strcpy(tmp_ptr, tmp_ptr+121);
50 if(cmd==ARJ_CMD_ORDER&&strpbrk(tmp_ptr, wildcard_pattern)!=NULL)
51 error(M_ORDER_WILDCARD);
54 @@ -696,7 +696,7 @@ int resolve_longname(char *dest, char *n
55 tmp_name[st_len]='\0';
56 if(tmp_name[0]==0xFD&&tmp_name[1]==0xFF)
58 - strcpy(tmp_name, (char *)tmp_name+4);
59 + safe_strcpy(tmp_name, (char *)tmp_name+4);
62 if(st_len==0||st_len+entry>=FILENAME_MAX)
65 @@ -578,7 +578,7 @@ int main(int argc, char **argv)
67 strcat(pool[tpool].data, msgname);
68 strcat(pool[tpool].data, ", ");
69 - strcpy(msg_buffer, msg_buffer+1);
70 + safe_strcpy(msg_buffer, msg_buffer+1);
71 buf_len=strlen(msg_buffer);
72 msg_buffer[--buf_len]='\0';
73 patch_string(msg_buffer);
76 @@ -347,7 +347,7 @@ int main(int argc, char **argv)
77 expand_tags(buf, sizeof(buf)-1);
78 if((p=strchr(buf, '.'))!=NULL)
81 + safe_strcpy(p, p+1);
82 if((p=strchr(buf, '.'))!=NULL)
91 +/* A safe strcpy() */
93 +#define safe_strcpy(dest, src) memmove(dest, src, strlen(src)+1);
95 /* ASCIIZ string copy macro */
97 #define strcpyn(dest, src, n) \