[comp.binaries.ibm.pc.d] Bug in APPENV

phillipg@microsoft.UUCP (Phillip Garding) (10/19/89)

I have just decoded and tried out Mark Lord's program APPENV, and I
have discovered a rather nasty bug.  The documentation doesn't include
an email address for the author, so I am posting it here; if anyone
knows Mark's address, please bring this bug to his attention.	

In my environment I have these two variables:
	TERM=vt52
	TERMCAP=c:\editors\termcap

As a test, I was going to append to my TERM variable.  I entered:
	APPENV TERM = hello (with the spaces)

I expected to see TERM=vt52hello; what was actually in my environment was
	TERM=vt52
	TERM=P=c:\editors\termcaphello

This bug appears if you define a new variable that begins with the same 
letters as a previously existing variable.  The problem seems to be with the
spaces, since it doesn't do it if I type APPENV TERM=hello.  In that case
I get the expected result.

 
                     II
      ( MOOOOOO ! )  II\
  ________\   /      II +    (__) ..oo( Hey, there's a cow driving that car! )
 |\        `v' \      + II   (00) 
 | \________|____\     \II\   \/-------\
 | (     ( @ @ )  )     II +    ||    ||\      (__) ..oo ( How can he     )
 |\|______\_O_/___|      + II   ||----|| *     (oo)        ( afford that? )
 | \_______________\      \II\  ~~    ~~        \/--------\
 \ (OO_##########_OO)      II +                    ||    || \
  \(_____[PHIL]_____)       + II--+--+--+-II-+--+--+--II+--+--+--+II--+--+-
     (_)        (_)          \II          II       ~~ II ~~       II
                              II--+--+--+-II-+--+--+--II+--+--+--+II--+--+-

You can call me Phil or you can call me Phillip or you can call me
Phillip Garding, but you doesn't have to call me phillipg@microsoft.

Subject: Bug in APPENV
Newsgroups: comp.binaries.ibm.pc.d
Keywords: appenv bug

I have just decoded and tried out Mark Lord's program APPENV, and I
have discovered a rather nasty bug.  The documentation doesn't include
an email address for the author, so I am posting it here; if anyone
knows Mark's address, please bring this bug to his attention.	

In my environment I have these two variables:
	TERM=vt52
	TERMCAP=c:\editors\termcap

As a test, I was going to append to my TERM variable.  I entered:
	APPENV TERM = hello (with the spaces)

I expected to see TERM=vt52hello; what was actually in my environment was
	TERM=vt52
	TERM=P=c:\editors\termcaphello

This bug appears if you define a new variable that begins with the same 
letters as a previously existing variable.  The problem seems to be with the
spaces, since it doesn't do it if I type APPENV TERM=hello.  In that case
I get the expected result.

Phillip Garding, phillipg@microsoft

mlord@bnr-rsc.UUCP (Mark Lord) (10/21/89)

In article <8111@microsoft.UUCP> phillipg@microsoft.UUCP (Phillip Garding) writes:
>I have just decoded and tried out Mark Lord's program APPENV, and I
>have discovered a rather nasty bug.  The documentation doesn't include
>...
>In my environment I have these two variables:
>	TERM=vt52
>	TERMCAP=c:\editors\termcap
>
>As a test, I was going to append to my TERM variable.  I entered:
>	APPENV TERM = hello (with the spaces)
>
>I expected to see TERM=vt52hello; what was actually in my environment was
>	TERM=vt52
>	TERM=P=c:\editors\termcaphello
>
>This bug appears if you define a new variable that begins with the same 
>letters as a previously existing variable.  The problem seems to be with the
>spaces, since it doesn't do it if I type APPENV TERM=hello.  In that case
>I get the expected result.

Good one!  Yes, everything does indeed work just fine without spaces before
the equal sign.  I have now fixed this and will be sending APPENV version 2.1
to SIMTEL20 to replace (buggy) version 2.0 there.  Probably not worth a repost
to comp.binaries.ibm.pc though.  

To fix this bug in the source, simply change line 92 of appenv.c as follows:

	OLD line 92:	while ((*e++ == *v++) && (*v));
	NEW line 92:	while (*e == *v) ++v, ++e;

Then recompile appenv.c under the TINY model of turbo-c, and use TLINK with
the /t option to create a new APPENV.COM.  If anyone is really desparate,
email me (by replying to this message from within rn) and I'll consider 
forwarding you the updated version.

Cheers,

-Mark

utgpu!bnr-vpa!bnr-fos!mlord%bmers58