Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Apache with modssl+OpenSSL cause csh script core dump ??

17 views
Skip to first unread message

Rich Teer

unread,
Jun 26, 2000, 3:00:00 AM6/26/00
to
On Tue, 27 Jun 2000, Lydia Chan wrote:

> I've installed Apache 1.3.11 with Modssl 2.5.1 and Openssl 0.9.4 in Solaris 2.6.
> If I start Apache together with SSL, no matter I point to it's general http
> port or ssl https port, for some program, a very simple example shown
> below, then it (the scripts) will core dump.
>
> My cgi scripts:
> #!/usr/bin/csh

I don't know the answer to your specific question, but you're not doing
yourself any favours by using csh as a scripting language. It's fine as
an interactive shell, but you really should use sh for scripts.

> I can't change machine, I don't prefer to rebuild server or add patches ('coz it's production server),
> I must need SSL, I must keep the "set noglob", I must kept the "#!/usr/bin/csh", and I must use

Why "must" you use csh?

--
Rich Teer

NT tries to do almost everything UNIX does, but fails - miserably.

The use of Windoze cripples the mind; its use should, therefore, be
regarded as a criminal offence. (With apologies to Edsger W. Dijkstra)

Voice: +1 (250) 979-1638
WWW: www.rite-group.com


Lydia Chan

unread,
Jun 27, 2000, 3:00:00 AM6/27/00
to
I've installed Apache 1.3.11 with Modssl 2.5.1 and Openssl 0.9.4 in Solaris 2.6.
If I start Apache together with SSL, no matter I point to it's general http
port or ssl https port, for some program, a very simple example shown
below, then it (the scripts) will core dump.

My cgi scripts:
#!/usr/bin/csh
set noglob
printf 'Content-type: text/html\n\n'
printf 'Hello<br>'
set QUERY=`echo 'abc=000&cde=890&xyz=889'`
set ret=`echo $QUERY |cut -f1 -d'&'|cut -f2 -d'='`
printf $ret'<br>'

I have tested with some more conditions, & resulted as:
If only start apache without SSL,
then it's fine.
If started apache with SSL,
if I comment the line "set noglob", it's fine.
If not comment "set noglob", while comment set ret=`echo $QUERY |cut -f1
-d'&'|cut -f2 -d'='`, it also fine.
If not comment "set noglob", change set ret=`echo $QUERY |cut -f1 -d'&'|cut
-f2 -d'='` to become set ret=`echo $QUERY`, it's fine.
If not comment "set noglob", change to set ret=`echo $QUERY|cut -f1`, there
is core dump...

If I change the #!/usr/bin/csh to #!/usr/local/bin/tcsh, other things unchanged, it also fine.
If I copied the whole apache directory into another machine, and start with SSL, it's also fine.

My problem:


I can't change machine, I don't prefer to rebuild server or add patches ('coz it's production server),
I must need SSL, I must keep the "set noglob", I must kept the "#!/usr/bin/csh", and I must use

pipe... that means I must find out what's the problem...

Any help is appreciated!

Regards,
Lydia.


Ken Pizzini

unread,
Jun 27, 2000, 3:00:00 AM6/27/00
to
On Tue, 27 Jun 2000 00:31:30 +0800, Lydia Chan <lyd...@netvigator.com> wrote:
>My cgi scripts:
>#!/usr/bin/csh

Ouch.

>set noglob
>printf 'Content-type: text/html\n\n'
>printf 'Hello<br>'
>set QUERY=`echo 'abc=000&cde=890&xyz=889'`

Why the indirection through `echo`? Why not just:
set QUERY='abc=000&cde=890&xyz=889'
?

>set ret=`echo $QUERY |cut -f1 -d'&'|cut -f2 -d'='`

I don't remember my csh quoting rules: can the &s in $QUERY
cause you grief? Just to be on the safe side:
set ret=`echo "$QUERY:q" |cut -f1 -d'&'|cut -f2 -d'='`

>printf $ret'<br>'

It is safest to never use a variable as part of the first
argument to printf:
printf '%s<br>' "$ret:q"


>I have tested with some more conditions, & resulted as:
>If only start apache without SSL,
> then it's fine.
>If started apache with SSL,
> if I comment the line "set noglob", it's fine.
> If not comment "set noglob", while comment set ret=`echo $QUERY |cut -f1
> -d'&'|cut -f2 -d'='`, it also fine.
> If not comment "set noglob", change set ret=`echo $QUERY |cut -f1 -d'&'|cut
> -f2 -d'='` to become set ret=`echo $QUERY`, it's fine.
> If not comment "set noglob", change to set ret=`echo $QUERY|cut -f1`, there
> is core dump...
>
>If I change the #!/usr/bin/csh to #!/usr/local/bin/tcsh, other things unchanged, it also fine.

Like I said when I first saw the #!/usr/bin/csh line: Ouch!

>I can't change machine, I don't prefer to rebuild server or add
>patches ('coz it's production server), I must need SSL, I must
>keep the "set noglob", I must kept the "#!/usr/bin/csh", and I
>must use pipe... that means I must find out what's the
>problem...

Two choices: bug in csh (in which case you don't get to fulfill
all of your requirements --- but why-oh-why is csh one of the
requirements!?), or quoting problems, which I may or may not
have solved in my suggested replacement for your "set ret=" line.

--Ken Pizzini

Lydia Chan

unread,
Jun 28, 2000, 3:00:00 AM6/28/00
to

Ken Pizzini wrote in message <8j9fkj$3mb$2...@brokaw.wa.com>...

>On Tue, 27 Jun 2000 00:31:30 +0800, Lydia Chan <lyd...@netvigator.com> wrote:
>>set QUERY=`echo 'abc=000&cde=890&xyz=889'`
>Why the indirection through `echo`? Why not just:
> set QUERY='abc=000&cde=890&xyz=889'

Just because I want to complicate some line and simplify some line and to find out
what exact stuff will make segmentation core dump... This indirection didn't cause
core dump. If I don't use indirection, core dump in next few line still appear...

>>set ret=`echo $QUERY |cut -f1 -d'&'|cut -f2 -d'='`
>
>I don't remember my csh quoting rules: can the &s in $QUERY
>cause you grief? Just to be on the safe side:
> set ret=`echo "$QUERY:q" |cut -f1 -d'&'|cut -f2 -d'='`

Just tried but problem still exist when run to this line...

>It is safest to never use a variable as part of the first
>argument to printf:
> printf '%s<br>' "$ret:q"

Also tried this but not work...
Just curious why it is not safe?

>Like I said when I first saw the #!/usr/bin/csh line: Ouch!

Do you mean csh has a lot of bugs ?

>Two choices: bug in csh (in which case you don't get to fulfill
>all of your requirements --- but why-oh-why is csh one of the
>requirements!?), or quoting problems, which I may or may not
>have solved in my suggested replacement for your "set ret=" line.

Because the real problem scripts are a number of long scripts....
I just identified and extract the part that create core dump.
They use csh and it will take long time to change all of them...

I have one more finding:
If I add this: set ret=''
before this: set ret=`echo "$QUERY:q" |cut -f1 -d'&'|cut -f2 -d'='`

then the problem solved...

Any more idea ?

Thanks a lot !

Regards,
Lydia.

Lydia Chan

unread,
Jun 29, 2000, 3:00:00 AM6/29/00
to
Finally I've changed the csh to tcsh and seems all the things works...
hope this persistent.

Thanks all who've helped.

Regards,
Lydia.

Lydia Chan wrote in message <8jaivd$4q...@imsp212.netvigator.com>...

Ken Pizzini

unread,
Jun 29, 2000, 3:00:00 AM6/29/00
to
On Thu, 29 Jun 2000 00:42:32 +0800, Lydia Chan <lyd...@netvigator.com> wrote:
>Lydia Chan wrote in message <8jaivd$4q...@imsp212.netvigator.com>...
>>Ken Pizzini wrote in message <8j9fkj$3mb$2...@brokaw.wa.com>...
>>>On Tue, 27 Jun 2000 00:31:30 +0800, Lydia Chan <lyd...@netvigator.com> wrote:
>>>It is safest to never use a variable as part of the first
>>>argument to printf:
>>> printf '%s<br>' "$ret:q"
>>
>>Also tried this but not work...
>>Just curious why it is not safe?

What if the variable contains a % or \ escape in it? Most of
the time you just want that % or \ to pass through unchanged,
and so never using a variable in the first argment is a good
habit to be in. Then again, "never" is too strong a word:
sometime you _do_ want a variable to be interpolated for the
formatting commands that it contains, but unless you explicitly
know that this is the case, use %s.

>>>Like I said when I first saw the #!/usr/bin/csh line: Ouch!
>>
>>Do you mean csh has a lot of bugs ?

Yup!

>>I have one more finding:
>>If I add this: set ret=''
>>before this: set ret=`echo "$QUERY:q" |cut -f1 -d'&'|cut -f2 -d'='`
>>
>>then the problem solved...

If adding that one trivial initialization is all that stands
between a core dump and a (presumably) successful run, then
the only explaination is a bug in csh; probably a buffer overrun
or a wild pointer dereference somewhere in its C code.

>Finally I've changed the csh to tcsh and seems all the things works...
>hope this persistent.

The upgrade to tcsh will certainly help a lot. It still has the
problems inherent in csh syntax, but at least it isn't so buggy,
and if/when one does uncover a bug it can be fixed.

--Ken Pizzini

0 new messages