[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#778773: [PATCH] Likely fix for crash



Control: tag -1 patch pending

Lennart Sorensen <lsorense@csclub.uwaterloo.ca> (2015-03-04):
> It seems to me inspecting the code of parted_server.c that:
> 
>                 deactivate_exception_handler();
>                 fstype = ped_file_system_probe(&(part->geom));
>                 if (fstype == NULL) {
>                         oprintf("none\n");
>                 } else {
>                         if (0 == strncmp(part->fs_type->name, "linux-swap", 10))
>                                 oprintf("linux-swap\n");
>                         else
>                                 oprintf("%s\n", fstype->name);
>                 }
>                 free(id);
> 
> should instead be:
> 
>                 deactivate_exception_handler();
>                 fstype = ped_file_system_probe(&(part->geom));
>                 if (fstype == NULL) {
>                         oprintf("none\n");
>                 } else {
>                         if (0 == strncmp(fstype->name, "linux-swap", 10))  <--- changed
>                                 oprintf("linux-swap\n");
>                         else
>                                 oprintf("%s\n", fstype->name);
>                 }
>                 free(id);
> 
> After all I see no reason why part->fs_type->name should even be
> initialized at that point, while fstype->name was just initialized and
> is used in the else.  That would explain the segfault.
> 
> I suspect a cut and paste error from elsewhere in the file.  After all line
> 1066 has the same strncmp, except there it is correct to use
> part->fs_type->name.

Wow, I'm glad I had been busy with other bits while you were discovering
this. This seems spot-on!

And your hypothesis seems totally plausible, let's look at
d56c74f310b02af4f81e5f5a5ba65b55fdbdc34e[1]:
| Adapt parted_server code to handle new GNU Parted swap filesystem handling.
| 
| r59025

 1. http://anonscm.debian.org/cgit/d-i/partman-base.git/commit/?id=d56c74f310b02af4f81e5f5a5ba65b55fdbdc34e

I could imagine how tempting it would be to copy-paste between
partition_info() and command_get_file_system(). The former deals with
part->[…] stuff, while the latter deals with fstype.

I'm very tempted to get the fix uploaded ASAP so that people can toy
around, even if I don't do any testing myself. I don't see how it could
possibly become worse than the current state of affairs.

Many thanks, Lennart!

Mraw,
KiBi.

Attachment: signature.asc
Description: Digital signature


Reply to: