From: s902113@minyos.xx.rmit.oz.au (Luke Mewburn)
Newsgroups: rec.games.mud.lp
Subject: Re: sprintf-v1.05 bug fix
Date: 12 Nov 1992 13:10:19 GMT
Organization: RMIT Computer Centre
NNTP-Posting-Host: minyos.xx.rmit.oz.au
Keywords: sprintf,bug fix

K111114@kuemmel2.edvz.uni-linz.ac.at (Herbert Rosmanith) writes:

>
> [Bug report in sprintf code deleted.]
>
>BUG - FIX
>=========
>
>The following is the diff -c file:
>*** sprintf.c	Sat Nov  7 00:46:51 1992
>--- sprintf.old	Sat Feb  8 05:30:12 1992
>***************
>*** 140,146 ****
>  #define ERR_QUOTE_EXPECTED	0xA	/* expected ' not found */
>  #define ERR_UNEXPECTED_EOS	0xB	/* fs terminated unexpectedly */
>  #define ERR_NULL_PS		0xC	/* pad string is null */
>- #define ERR_ARRAY_EXPECTED	0xD	/* array expected */
>  
>  #define ADD_CHAR(x) {\
>    buff[bpos++] = x;\
>--- 140,145 ----
>***************
>*** 526,534 ****
>        case ERR_NULL_PS:
>          err = "Null pad string specified.";
>          break;
>-       case ERR_ARRAY_EXPECTED:
>- 	err = "Array expected.";
>- 	break;
>        default:
>  #ifdef RETURN_ERROR_MESSAGES
>          sprintf(buff,
>--- 525,530 ----
>***************
>*** 689,696 ****
>         * now handle the different arg types...
>         */
>        if (finfo & INFO_ARRAY) {
>- 	if (carg->type != T_POINTER)
>- 	  ERROR(ERR_ARRAY_EXPECTED);
>          if (carg->u.vec->size == 0) {
>            fpos--; /* 'bout to get incremented */
>            continue;
>--- 685,690 ----
>
>[ idea for new data type deleted.]
>

Ok, I'm not flaming, so don't take it personally, but you did a minor
booboo in yer diff -c, you got the args the wrong way around. That
diff will _remove_ the code to fix the bug from a patched source.
I think you meant to do: diff -c sprintf.old sprintf.c >diffs
instead.

Anyway, here is a modified version of yer patch (I.e, I edited the
src as you intended and ran diff myself:) which *should* work:

-- bug fix patch: run it through patch -p -N < thispatch --
*** sprintf.old	Fri Nov 13 01:02:55 1992
--- sprintf.c	Fri Nov 13 01:05:33 1992
***************
*** 140,145 ****
--- 140,146 ----
  #define ERR_QUOTE_EXPECTED	0xA	/* expected ' not found */
  #define ERR_UNEXPECTED_EOS	0xB	/* fs terminated unexpectedly */
  #define ERR_NULL_PS		0xC	/* pad string is null */
+ #define ERR_ARRAY_EXPECTED	0xD	/* array expected */
  
  #define ADD_CHAR(x) {\
    buff[bpos++] = x;\
***************
*** 525,530 ****
--- 526,534 ----
        case ERR_NULL_PS:
          err = "Null pad string specified.";
          break;
+       case ERR_ARRAY_EXPECTED:
+         err = "Array expected.";
+         break;
        default:
  #ifdef RETURN_ERROR_MESSAGES
          sprintf(buff,
***************
*** 685,690 ****
--- 689,696 ----
         * now handle the different arg types...
         */
        if (finfo & INFO_ARRAY) {
+         if (carg->type != T_POINTER)
+           ERROR(ERR_ARRAY_EXPECTED);
          if (carg->u.vec->size == 0) {
            fpos--; /* 'bout to get incremented */
            continue;
-- --

>-----------------------------------------------------------------------------
>Please don't send mail to this machine, since this is a PC without a mailer.
>Had to use it coz of troubles with the newsreader of the VMXA :->
>If you wan't to send me mail, please reply to:
>K111114@alijku11.bitnet

>Thanks and bye, Herp.

No probs

Newsgroups: rec.games.mud.lp