Bug#647326: zfs-fuse: fails to run, segfault or invalid option due to wrong argv[0] when read cfg file is called from main

November 01st, 2011 - 04:50 pm ET by Alban Browaeys | Report spam
This is a multi-part MIME message sent by reportbug.


MIME-Version: 1.0

Package: zfs-fuse
Version: 0.7.0-2
Severity: important

zfs-fuse fails to start and either segfault or report an invalid long
option. Attached is a patch that initialize argv[O] in read_cfg, ie
it currently point to unitialized memory and this memory is read when
there is an option passed to zfs-fuse.
I also comment the /etc/zfs/zfsrc argument as it seems it is not a valid
argument.
Patch compile and run.

Debian Release: wheezy/sid
APT prefers unstable
APT policy: (500, 'unstable'), (500, 'testing'), (1, 'experimental')
Architecture: amd64 (x86_64)

Kernel: Linux 3.1.0test0 (SMP w/2 CPU cores)
Locale: LANG=fr_FR.utf8, LC_CTYPE=fr_FR.utf8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages zfs-fuse depends on:
ii fuse-utils 2.8.6-2
ii libaio1 0.3.109-2
ii libc6 2.13-21
ii libfuse2 2.8.6-2
ii libssl1.0.0 1.0.0e-2
ii lsb-base 3.2-28
ii zlib1g 1:1.2.5.dfsg-1

zfs-fuse recommends no packages.

Versions of packages zfs-fuse suggests:
ii kpartx 0.4.9-2
ii nfs-kernel-server 1:1.2.5-2


MIME-Version: 1.0
filename="feed-parse-args-with-progname-when-using-zfsrc.diff"

Description: feed parse_args with the program name when using zfsrc
Provide the program name as argv[0] as parse_args expect it to be there.
Otherwise the with argv[argc++] item 0 of agrv points to uninitialized
memory and random crashes or failure due to incorrect long_opts ensue.
Also comment the /etc/zfs/zfsrc argv item as there is no such option and
it breaks long_opts with error:
"unrecognized option '--/etc/zfs/zfsrc'"

Author: Alban Browaeys <prahal@yahoo.com>



zfs-fuse-0.7.0.orig/src/zfs-fuse/main.c
+++ zfs-fuse-0.7.0/src/zfs-fuse/main.c
@@ -358,15 +358,18 @@ static void read_cfg() {
return;
while (!feof(f)) {
char buf[1024];
- int argc = 0;
- char *argv[10];
+ int argc = 1;
+ char *argv[11];
+
+ argv[0] = "zfs-fuse";
+
if (!fgets(buf,1024,f))
continue;
int l = strlen(buf)-1;
while (l >= 0 && buf[l] < 32)
buf[l--] = 0; // remove trailing cr (or any code < ' ')

- argv[argc++] = "/etc/zfs/zfsrc";
+ //argv[argc++] = "/etc/zfs/zfsrc";

////////////////////////////////////////////
// more predictable parsing required




To UNSUBSCRIBE, email to debian-bugs-dist-REQUEST@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmaster@lists.debian.org
email Follow the discussionReplies 1 replyReplies Make a reply

Replies

#1 Asias He
November 02nd, 2011 - 02:30 am ET | Report spam
tags 647326 confirmed
thanks

On 11/02/2011 05:44 AM, Alban Browaeys wrote:
Package: zfs-fuse
Version: 0.7.0-2
Severity: important

zfs-fuse fails to start and either segfault or report an invalid long
option. Attached is a patch that initialize argv[O] in read_cfg, ie
it currently point to unitialized memory and this memory is read when
there is an option passed to zfs-fuse.
I also comment the /etc/zfs/zfsrc argument as it seems it is not a valid
argument.
Patch compile and run.



Hi, Alban


Martin also found this problem, so I am CC'ing him.

Thanks for the patch. I can reproduce this bug on 64bit box only. It
seems 32bit box does not have this problem.

I tried your patch, however, the segfault is still there. Did the patch
work for you?

Asias He



To UNSUBSCRIBE, email to
with a subject of "unsubscribe". Trouble? Contact

Similar topics