poeml / mirrorbrain

MirrorBrain
http://mirrorbrain.org/
Other
75 stars 44 forks source link

realpath(in,out) on Solaris must receive a valid buffer for out #145

Closed poeml closed 9 years ago

poeml commented 9 years ago
                                                                                                                                                   [          ]

Issue migrated (2015-06-05) from old issue tracker http://mirrorbrain.org/issues/issue145

Title    realpath(in,out) on Solaris must receive a valid buffer for out
 Priority   urgent             Status       resolved
Superseder                   Nosy List      dagobert, poeml
Assigned To                   Keywords
msg516 (view) Author: dagobert Date: 2014-02-03.21:26:49

On Solaris the function realpath(const char * restrict pathname, char * restrict resolved_path); must receive a valid buffer pointer as resolved_path. In mirrorbrain there is passed NULL instead: 62 ptr = realpath(cfg->mirror_base, NULL); as taken from

https://buildfarm.opencsw.org/source/xref/mirrorbrain/mod_mirrorbrain/mod_mirrorbrain.c

1862

The resolved_path must be pre-allocated and can be up to PATH_MAX bytes long as defined in limits.h

msg517 (view) Author: dagobert Date: 2014-02-03.21:29:14

There is also another occurrence at https://buildfarm.opencsw.org/source/xref/mirrorbrain/mod_mirrorbrain/mod_mirrorbrain.c#1882

msg522 (view) Author: poeml Date: 2014-02-04.23:46:12

Are you sure? Am I reading the wrong man page here? http://docs.oracle.com/cd/E23824_01/html/821-1465/realpath-3c.html#REFMAN3Arealpath- 3c (Just googled... I don't know if it's applicable to your system)

msg523 (view) Author: dagobert Date: 2014-02-05.10:26:34

The behavior changed in Solaris 11 which docs you are referring. In Solaris 10 the second parameter must not be null: https://www.gnu.org/software/gnulib/manual/html_node/realpath.html This patch resolves my issue: https://buildfarm.opencsw.org/source/xref/opencsw/csw/mgar/pkg/mirrorbrain/trunk/files/0001-realpath-must-get-preallocated-memory-on-Solaris.patch The verification of the malloc result should not be necessary as realpath would fall through to the existing error we were seeing before.

msg526 (view) Author: poeml Date: 2014-02-05.23:06:09

Ah, I see!

But we can probably just use

ptr = apr_palloc(r->pool, APR_PATH_MAX);

on all platforms where the second realpath() argument may be preallocated.

Freeing pool memory happens automatically after a request is handled, which is very handy.

msg529 (view) Author: poeml Date: 2014-02-07.00:04:04

I committed a fix in r8388. http://svn.mirrorbrain.org/viewvc/mirrorbrain?view=revision&revision=8388

If you want to test, feel free :-) You'll find a tarball from trunk (2.19.0, don't tell anyone! ;) here: http://mirrorbrain.org/files/releases/

msg533 (view) Author: dagobert Date: 2014-02-09.11:26:13

The fix works, thank you!

msg536 (view) Author: poeml Date: 2014-02-09.12:54:53

Thanks for the confirmation!

History
         Date           User   Action            Args
2014-02-09 12:54:53 poeml    set    status: testing -> resolved
                                      messages: + msg536
2014-02-09 11:26:13 dagobert set    messages: + msg533
2014-02-07 00:04:05 poeml    set    status: chatting -> testing
                                      messages: + msg529
2014-02-05 23:06:09 poeml    set    messages: + msg526
2014-02-05 10:26:34 dagobert set    messages: + msg523
2014-02-04 23:46:12 poeml    set    nosy: + poeml
                                      messages: + msg522
2014-02-03 21:29:14 dagobert set    status: unread -> chatting
                                      messages: + msg517
2014-02-03 21:26:49 dagobert create
(end of migrated issue)