dskvr / opkg

Automatically exported from code.google.com/p/opkg
0 stars 0 forks source link

fdopen(fd, "rw+") returns invalid stream on Solaris sparc #30

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
In http://code.google.com/p/opkg/source/browse/trunk/libopkg/pkg.c there're
2 places with "rw+"

On Solaris 10 (SunOS aaaa 5.10 Generic_137137-09 sun4u sparc
SUNW,Sun-Fire-280R) I get segfault when trying to install a package.

Found that this happens because NULL pkg->name vararg was passed to vsnprintf:
http://code.google.com/p/opkg/source/browse/trunk/libopkg/opkg_download.c?r=339#
303

This in turn is because the unpacked ./control file not gets written to a
temporary file. fputs() fails here:
http://code.google.com/p/opkg/source/browse/trunk/libopkg/pkg_extract.c?r=339#40

Invalid stream returned by fdopen():
http://code.google.com/p/opkg/source/browse/trunk/libopkg/pkg.c?r=339#332

If I change this to "w+" at least this problem is solved.

Note that there's another place with "rw+":
http://code.google.com/p/opkg/source/browse/trunk/libopkg/pkg.c?r=339#1047

What is "rw+"? Can't find this in man or msdn.

Original issue reported on code.google.com by basini...@gmail.com on 20 Nov 2009 at 11:13

GoogleCodeExporter commented 8 years ago
rw+ appears to be accepted by linux. But you're right, it is not in the manual 
and should not be relied upon.

Original comment by graham.g...@gmail.com on 20 Nov 2009 at 8:33

GoogleCodeExporter commented 8 years ago
mkstemp should create the file, so I've changed "rw+" to "r+" in r345. Please 
reopen if you have any further problems.

Original comment by graham.g...@gmail.com on 22 Nov 2009 at 11:27