diff options
Diffstat (limited to 'fs/coredump.c')
-rw-r--r-- | fs/coredump.c | 44 |
1 files changed, 21 insertions, 23 deletions
diff --git a/fs/coredump.c b/fs/coredump.c index 2b1d1f54e630..90d7cee54347 100644 --- a/fs/coredump.c +++ b/fs/coredump.c | |||
@@ -99,11 +99,21 @@ static int cn_printf(struct core_name *cn, const char *fmt, ...) | |||
99 | return ret; | 99 | return ret; |
100 | } | 100 | } |
101 | 101 | ||
102 | static void cn_escape(char *str) | 102 | static int cn_esc_printf(struct core_name *cn, const char *fmt, ...) |
103 | { | 103 | { |
104 | for (; *str; str++) | 104 | int cur = cn->used; |
105 | if (*str == '/') | 105 | va_list arg; |
106 | *str = '!'; | 106 | int ret; |
107 | |||
108 | va_start(arg, fmt); | ||
109 | ret = cn_vprintf(cn, fmt, arg); | ||
110 | va_end(arg); | ||
111 | |||
112 | for (; cur < cn->used; ++cur) { | ||
113 | if (cn->corename[cur] == '/') | ||
114 | cn->corename[cur] = '!'; | ||
115 | } | ||
116 | return ret; | ||
107 | } | 117 | } |
108 | 118 | ||
109 | static int cn_print_exe_file(struct core_name *cn) | 119 | static int cn_print_exe_file(struct core_name *cn) |
@@ -113,12 +123,8 @@ static int cn_print_exe_file(struct core_name *cn) | |||
113 | int ret; | 123 | int ret; |
114 | 124 | ||
115 | exe_file = get_mm_exe_file(current->mm); | 125 | exe_file = get_mm_exe_file(current->mm); |
116 | if (!exe_file) { | 126 | if (!exe_file) |
117 | char *commstart = cn->corename + cn->used; | 127 | return cn_esc_printf(cn, "%s (path unknown)", current->comm); |
118 | ret = cn_printf(cn, "%s (path unknown)", current->comm); | ||
119 | cn_escape(commstart); | ||
120 | return ret; | ||
121 | } | ||
122 | 128 | ||
123 | pathbuf = kmalloc(PATH_MAX, GFP_TEMPORARY); | 129 | pathbuf = kmalloc(PATH_MAX, GFP_TEMPORARY); |
124 | if (!pathbuf) { | 130 | if (!pathbuf) { |
@@ -132,9 +138,7 @@ static int cn_print_exe_file(struct core_name *cn) | |||
132 | goto free_buf; | 138 | goto free_buf; |
133 | } | 139 | } |
134 | 140 | ||
135 | cn_escape(path); | 141 | ret = cn_esc_printf(cn, "%s", path); |
136 | |||
137 | ret = cn_printf(cn, "%s", path); | ||
138 | 142 | ||
139 | free_buf: | 143 | free_buf: |
140 | kfree(pathbuf); | 144 | kfree(pathbuf); |
@@ -207,22 +211,16 @@ static int format_corename(struct core_name *cn, struct coredump_params *cprm) | |||
207 | break; | 211 | break; |
208 | } | 212 | } |
209 | /* hostname */ | 213 | /* hostname */ |
210 | case 'h': { | 214 | case 'h': |
211 | char *namestart = cn->corename + cn->used; | ||
212 | down_read(&uts_sem); | 215 | down_read(&uts_sem); |
213 | err = cn_printf(cn, "%s", | 216 | err = cn_esc_printf(cn, "%s", |
214 | utsname()->nodename); | 217 | utsname()->nodename); |
215 | up_read(&uts_sem); | 218 | up_read(&uts_sem); |
216 | cn_escape(namestart); | ||
217 | break; | 219 | break; |
218 | } | ||
219 | /* executable */ | 220 | /* executable */ |
220 | case 'e': { | 221 | case 'e': |
221 | char *commstart = cn->corename + cn->used; | 222 | err = cn_esc_printf(cn, "%s", current->comm); |
222 | err = cn_printf(cn, "%s", current->comm); | ||
223 | cn_escape(commstart); | ||
224 | break; | 223 | break; |
225 | } | ||
226 | case 'E': | 224 | case 'E': |
227 | err = cn_print_exe_file(cn); | 225 | err = cn_print_exe_file(cn); |
228 | break; | 226 | break; |