~ubuntu-branches/ubuntu/trusty/rhash/trusty

« back to all changes in this revision

Viewing changes to debian/patches/rhash-1.2.7-fix-crash.patch

  • Committer: Bazaar Package Importer
  • Author(s): Aleksey Kravchenko
  • Date: 2011-08-14 20:35:00 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20110814203500-rvnovipwcpqkm91u
Tags: 1.2.7-1
* New upstream release version 1.2.7
 - Fixes security issue (Closes: #632280)
 - changed author/mantainer name to the way I prefer s/Alexey S/Aleksey/
 - simplified desriptions of binary packages
 - wriiten rules in more now standard way, using CFLAGS/LDFLAGS
 - reworded README.Debian a bit
 - aplied patch from upstream to fix possible segfault
 - aplied patch from upstream to fix glibc runtime warning
 - aplied patch from upstream to repair -openssl option handling

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
Description: fix segmentation fault running tests
 
2
 The patch fixes segmentation fault occurring on some systems,
 
3
 especially SUSE Linux, due too internal opt.files[] array not
 
4
 alwais ending with NULL. Insteed of just ending this array
 
5
 with NULL, the code was modified to track the size of opt.files[].
 
6
 
 
7
Origin: upstream https://github.com/rhash/RHash/commit/bee2338cbf9323531a0998a118d94936d39289e2
 
8
Author: Aleksey Kravchenko <rhash.admin@gmail.com>
 
9
Bug-RHash: https://sourceforge.net/tracker/?func=detail&aid=3391587&group_id=205103&atid=992288
 
10
Forwarded: sent-to-upstream
 
11
Last-Update: 2011-08-23
 
12
 
 
13
 
 
14
diff --git a/parse_cmdline.c b/parse_cmdline.c
 
15
index e47edba..42d2835 100644
 
16
--- a/parse_cmdline.c
 
17
+++ b/parse_cmdline.c
 
18
@@ -946,15 +946,15 @@ void read_options(int argc, char *argv[])
 
19
                for(; p > path && IS_PATH_SEPARATOR_W(*p) && p[-1] != L':'; p--) *p = 0;
 
20
                expand_wildcards(expanded_cnames, path);
 
21
        }
 
22
-       /* the following NULL marks the end of files */
 
23
-       if(cmd_line.n_files) rsh_vector_add_ptr(expanded_cnames, NULL);
 
24
 
 
25
        opt.cmd_vec = expanded_cnames;
 
26
        opt.files = (char**)expanded_cnames->array;
 
27
+       opt.n_files = (int)expanded_cnames->size;
 
28
        free(cmd_line.files);
 
29
        LocalFree(cmd_line.warg);
 
30
 #else
 
31
        opt.files = cmd_line.files;
 
32
+       opt.n_files = cmd_line.n_files;
 
33
        rsh_vector_add_ptr(opt.mem, opt.files);
 
34
 #endif
 
35
 
 
36
diff --git a/parse_cmdline.h b/parse_cmdline.h
 
37
index 481c506..1c8f799 100644
 
38
--- a/parse_cmdline.h
 
39
+++ b/parse_cmdline.h
 
40
@@ -78,7 +78,8 @@ struct options_t {
 
41
        unsigned openssl_mask;  /* mask which openssl hashes to use */
 
42
 
 
43
        char** argv;
 
44
-       char** files;
 
45
+       char** files; /* the files to process */
 
46
+       int n_files; /* the number of files */
 
47
        struct vector_t *cmd_vec; /* vector for command line arguments */
 
48
        struct vector_t *mem; /* heap variables that should be freed */
 
49
 };
 
50
diff --git a/rhash_main.c b/rhash_main.c
 
51
index 33b4ebc..ab81abb 100644
 
52
--- a/rhash_main.c
 
53
+++ b/rhash_main.c
 
54
@@ -145,24 +145,26 @@ static int load_printf_template(void)
 
55
  */
 
56
 static void print_sfv_file_header(void)
 
57
 {
 
58
+       int i;
 
59
+
 
60
        /* print SFV file header */
 
61
        if(opt.fmt == FMT_SFV && opt.mode == 0) {
 
62
-               char **f;
 
63
                print_sfv_banner(rhash_data.out);
 
64
 
 
65
-               for(f = opt.files; *f != NULL; f++) {
 
66
+               for(i = 0; i < opt.n_files; i++) {
 
67
+                       char *path = opt.files[i];
 
68
                        if(opt.flags & OPT_RECURSIVE) {
 
69
                                struct rsh_stat_struct stat_buf;
 
70
-                               if(rsh_stat(*f, &stat_buf) < 0) {
 
71
+                               if(rsh_stat(path, &stat_buf) < 0) {
 
72
                                        continue; /* don't report error here, it'll be reported later */
 
73
                                }
 
74
                                /* if file is a directory, then walk it recursively */
 
75
                                if(S_ISDIR(stat_buf.st_mode)) {
 
76
-                                       find_file(*f, find_file_callback, 0, opt.find_max_depth, (void*)1);
 
77
+                                       find_file(path, find_file_callback, 0, opt.find_max_depth, (void*)1);
 
78
                                        continue;
 
79
                                }
 
80
                        }
 
81
-                       print_sfv_header_line(rhash_data.out, *f, *f);
 
82
+                       print_sfv_header_line(rhash_data.out, path, path);
 
83
                }
 
84
                fflush(rhash_data.out);
 
85
        }
 
86
@@ -175,39 +177,40 @@ static void process_files(void)
 
87
 {
 
88
        timedelta_t timer;
 
89
        struct rsh_stat_struct stat_buf;
 
90
+       int i;
 
91
        rhash_timer_start(&timer);
 
92
        rhash_data.processed = 0;
 
93
 
 
94
        /* process filenames */
 
95
-       for (;*opt.files != NULL;opt.files++) {
 
96
+       for(i = 0; i < opt.n_files; i++) {
 
97
                int res = 0;
 
98
+               char* filepath = opt.files[i];
 
99
                stat_buf.st_mode = 0;
 
100
 
 
101
-               if(!IS_DASH_STR(*opt.files) && rsh_stat(*opt.files, &stat_buf) < 0) {
 
102
-                       log_file_error(*opt.files);
 
103
+               if(!IS_DASH_STR(filepath) && rsh_stat(filepath, &stat_buf) < 0) {
 
104
+                       log_file_error(filepath);
 
105
                        continue;
 
106
                }
 
107
                if(opt.flags & OPT_RECURSIVE) {
 
108
                        if(S_ISDIR(stat_buf.st_mode)) {
 
109
-                               find_file(*opt.files, find_file_callback, 0, opt.find_max_depth, NULL);
 
110
+                               find_file(filepath, find_file_callback, 0, opt.find_max_depth, NULL);
 
111
                                continue;
 
112
                        }
 
113
-               }
 
114
-               else{
 
115
+               } else {
 
116
                        if(S_ISDIR(stat_buf.st_mode)){
 
117
                                if(opt.flags & OPT_VERBOSE){
 
118
-                                       log_msg("warning: %s: is a directory\n", *opt.files);
 
119
+                                       log_msg("warning: %s: is a directory\n", filepath);
 
120
                                }
 
121
                                continue;
 
122
                        }
 
123
                }
 
124
 
 
125
                if(opt.mode & (MODE_CHECK | MODE_CHECK_EMBEDDED)) {
 
126
-                       res = check_hash_file(*opt.files, 0);
 
127
+                       res = check_hash_file(filepath, 0);
 
128
                } else if(opt.mode & MODE_UPDATE) {
 
129
-                       res = update_hash_file(*opt.files);
 
130
+                       res = update_hash_file(filepath);
 
131
                } else {
 
132
-                       res = calculate_and_print_sums(rhash_data.out, *opt.files, *opt.files, &stat_buf);
 
133
+                       res = calculate_and_print_sums(rhash_data.out, filepath, filepath, &stat_buf);
 
134
                        rhash_data.processed++;
 
135
                }
 
136
                if(res < 0) rhash_data.error_flag = 1;
 
137
@@ -264,7 +267,7 @@ int main(int argc, char *argv[])
 
138
                rsh_exit(0);
 
139
        }
 
140
 
 
141
-       if (opt.files == NULL || *opt.files == NULL) {
 
142
+       if(opt.n_files == 0) {
 
143
                if(argc > 1) {
 
144
                        log_msg("warning: no files/directories were specified at command line\n");
 
145
                }