Skip to content

Commit cacbe3d

Browse files
jeffmahoneytorvalds
authored andcommitted
reiserfs: prepare_error_buf wrongly consumes va_arg
vsprintf will consume varargs on its own. Skipping them manually results in garbage in the error buffer, or Oopses in the case of pointers. This patch removes the advancement and fixes a number of bugs where crashes were observed as side effects of a regular error report. Signed-off-by: Jeff Mahoney <jeffm@suse.com> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent 45b03d5 commit cacbe3d

1 file changed

Lines changed: 3 additions & 9 deletions

File tree

‎fs/reiserfs/prints.c‎

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -157,19 +157,16 @@ static void sprintf_disk_child(char *buf, struct disk_child *dc)
157157
dc_size(dc));
158158
}
159159

160-
static char *is_there_reiserfs_struct(char *fmt, int *what, int *skip)
160+
static char *is_there_reiserfs_struct(char *fmt, int *what)
161161
{
162162
char *k = fmt;
163163

164-
*skip = 0;
165-
166164
while ((k = strchr(k, '%')) != NULL) {
167165
if (k[1] == 'k' || k[1] == 'K' || k[1] == 'h' || k[1] == 't' ||
168166
k[1] == 'z' || k[1] == 'b' || k[1] == 'y' || k[1] == 'a') {
169167
*what = k[1];
170168
break;
171169
}
172-
(*skip)++;
173170
k++;
174171
}
175172
return k;
@@ -193,18 +190,15 @@ static void prepare_error_buf(const char *fmt, va_list args)
193190
char *fmt1 = fmt_buf;
194191
char *k;
195192
char *p = error_buf;
196-
int i, j, what, skip;
193+
int what;
197194

198195
strcpy(fmt1, fmt);
199196

200-
while ((k = is_there_reiserfs_struct(fmt1, &what, &skip)) != NULL) {
197+
while ((k = is_there_reiserfs_struct(fmt1, &what)) != NULL) {
201198
*k = 0;
202199

203200
p += vsprintf(p, fmt1, args);
204201

205-
for (i = 0; i < skip; i++)
206-
j = va_arg(args, int);
207-
208202
switch (what) {
209203
case 'k':
210204
sprintf_le_key(p, va_arg(args, struct reiserfs_key *));

0 commit comments

Comments
 (0)