wok-next view arj/stuff/patches/use_safe_strcpy.patch @ rev 20732
Some python-* packaged using pip: actualize $VERSION in genpkg_rules()
author | Aleksej Bobylev <al.bobylev@gmail.com> |
---|---|
date | Tue May 29 17:01:41 2018 +0300 (2018-05-29) |
parents | |
children |
line source
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
7 ---
8 arj.c | 2 +-
9 arjdata.c | 9 +--------
10 ea_mgr.c | 2 +-
11 misc.h | 4 ++++
12 msgbind.c | 2 +-
13 packager.c | 2 +-
14 6 files changed, 9 insertions(+), 12 deletions(-)
16 --- a/arjdata.c
17 +++ b/arjdata.c
18 @@ -204,13 +204,6 @@ void date_fmt(char *dest)
19 #endif
20 }
22 -/* A safe strcpy() */
23 -
24 -static void safe_strcpy(char *dest, char *src)
25 -{
26 - memmove(dest, src, strlen(src)+1);
27 -}
28 -
29 /* Context substitution routine */
31 char *expand_tags(char *str, int limit)
32 @@ -232,7 +225,7 @@ char *expand_tags(char *str, int limit)
33 {
34 if(*(p+1)==TAG_CHAR)
35 {
36 - strcpy(p, p+1);
37 + safe_strcpy(p, p+1);
38 p++;
39 }
40 else if(*(p+1)==TAG_SPECIAL_BEGIN&&(et=strchr(p+3, TAG_SPECIAL_END))!=NULL)
41 --- a/arj.c
42 +++ b/arj.c
43 @@ -1169,7 +1169,7 @@ int main(int argc, char *argv[])
44 if(strlen(tmp_ptr)<=121)
45 tmp_ptr[0]='\0';
46 else if(tmp_ptr[120]==' ')
47 - strcpy(tmp_ptr, tmp_ptr+121);
48 + safe_strcpy(tmp_ptr, tmp_ptr+121);
49 }
50 if(cmd==ARJ_CMD_ORDER&&strpbrk(tmp_ptr, wildcard_pattern)!=NULL)
51 error(M_ORDER_WILDCARD);
52 --- a/ea_mgr.c
53 +++ b/ea_mgr.c
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)
57 {
58 - strcpy(tmp_name, (char *)tmp_name+4);
59 + safe_strcpy(tmp_name, (char *)tmp_name+4);
60 st_len-=4;
61 }
62 if(st_len==0||st_len+entry>=FILENAME_MAX)
63 --- a/msgbind.c
64 +++ b/msgbind.c
65 @@ -578,7 +578,7 @@ int main(int argc, char **argv)
66 }
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);
74 --- a/packager.c
75 +++ b/packager.c
76 @@ -347,7 +347,7 @@ int main(int argc, char **argv)
77 expand_tags(buf, sizeof(buf)-1);
78 if((p=strchr(buf, '.'))!=NULL)
79 {
80 - strcpy(p, p+1);
81 + safe_strcpy(p, p+1);
82 if((p=strchr(buf, '.'))!=NULL)
83 *p='\0';
84 }
85 --- a/misc.h
86 +++ b/misc.h
87 @@ -11,6 +11,10 @@
88 #include "arjtypes.h"
89 #include "filelist.h"
91 +/* A safe strcpy() */
92 +
93 +#define safe_strcpy(dest, src) memmove(dest, src, strlen(src)+1);
94 +
95 /* ASCIIZ string copy macro */
97 #define strcpyn(dest, src, n) \