[110] in Kerberos-V5-bugs
bugs in freeing code in isode 6.0 pepy/posy
daemon@ATHENA.MIT.EDU (daemon@ATHENA.MIT.EDU)
Thu Feb 21 14:37:29 1991
Date: Thu, 21 Feb 91 14:37:14 -0500
From: John T Kohl <jtkohl@MIT.EDU>
To: bug-isode@nisc.nyser.net
Cc: krb5-bugs@MIT.EDU
Attached are patches to implement several fixes to the structure freeing code:
1) separate the free_* routines into separate output files (involves
some additional calculation to get the generic filename width wide
enough to hold all possible functions, even though this may result in
extra digits)
2) declare all the free_* routines as void, since they don't return any
values.
3) properly free structures which represent SEQUENCE OF types (their
main body needs to be freed, just like a SEQUENCE).
diff -rcbw /tmp/isode/pepy.c ./pepy.c
*** /tmp/isode/pepy.c Thu Feb 21 14:28:11 1991
--- ./pepy.c Thu Feb 21 14:28:16 1991
***************
*** 550,555 ****
--- 553,563 ----
if (!(sy -> sy_type -> yp_flags & YP_IMPORTED))
if (++i >= j)
bwidth++, j *= 10;
+ /* also need to account for possible FREE routines, which can number
+ up to 1/2 the encode/decoede routines */
+ while (i + i/2 + 1 >= j)
+ bwidth++, j *= 10;
+
}
else
prologue2 ();
***************
*** 2024,2027 ****
--- 2032,2068 ----
if (ferror (stdout))
myyerror ("write error - %s", sys_errname (errno));
+ }
+
+ pepy_finalize(txt, fp)
+ register char *txt;
+ FILE *fp;
+ {
+ char *nlp, *lastp;
+ int first = 1;
+
+ if (bflag) {
+ if (txt[0] == '\n') txt++;
+ lastp = txt;
+ for (;;) {
+ nlp = index(lastp, '\n');
+ if (!nlp) {
+ fputs(lastp, stdout);
+ break;
+ }
+ *nlp = 0;
+ if (!strcmp(lastp,"/*PY_BREAK*/")) {
+ if (!first) {
+ end_file();
+ init_new_file();
+ }
+ first = 0;
+ } else {
+ fputs(lastp, fp);
+ putc('\n', fp);
+ }
+ lastp = nlp+1;
+ }
+ } else
+ fputs(txt, fp);
}
diff -rcbw /tmp/isode/posy.c ./posy.c
*** /tmp/isode/posy.c Thu Feb 21 14:28:12 1991
--- ./posy.c Thu Feb 21 14:28:19 1991
***************
*** 936,942 ****
printag (yp, 4, pullup);
fprintf (fdef, "struct %s {\n", modsym (mymodule, id, "type"));
if (fflag) {
! fprintf (fact, "\n%s (arg)\n", modsym (mymodule, id, "free"));
fprintf (fact, "struct %s *arg;\n{\n",
modsym (mymodule, id, "type"));
fprintf (fact, " struct %s *parm = arg;\n",
--- 943,949 ----
printag (yp, 4, pullup);
fprintf (fdef, "struct %s {\n", modsym (mymodule, id, "type"));
if (fflag) {
! fprintf (fact, "/*PY_BREAK*/\nvoid\n%s (arg)\n", modsym (mymodule, id, "free"));
fprintf (fact, "struct %s *arg;\n{\n",
modsym (mymodule, id, "type"));
fprintf (fact, " struct %s *parm = arg;\n",
***************
*** 947,956 ****
}
posy (yp, 1, 1, "parm", id, "parm", flg && h2flag);
fprintf (fdef, "};\n");
! fprintf (fdef, "int\t%s ();\n", modsym (mymodule, id, "free"));
if (fflag) {
! if (yp -> yp_code != YP_SEQTYPE &&
! yp -> yp_code != YP_SETTYPE)
fprintf (fact, "\n free ((char *) arg);");
fprintf (fact, "\n}\n");
}
--- 954,962 ----
}
posy (yp, 1, 1, "parm", id, "parm", flg && h2flag);
fprintf (fdef, "};\n");
! fprintf (fdef, "void\t%s ();\n", modsym (mymodule, id, "free"));
if (fflag) {
! if (yp -> yp_code != YP_SETTYPE)
fprintf (fact, "\n free ((char *) arg);");
fprintf (fact, "\n}\n");
}
***************
*** 3327,3330 ****
--- 3333,3343 ----
default:
break;
}
+ }
+
+ pepy_finalize(txt, fp)
+ register char *txt;
+ FILE *fp;
+ {
+ fputs(txt, fp);
}
diff -rcbw /tmp/isode/yacc.y.gnrc ./yacc.y.gnrc
*** /tmp/isode/yacc.y.gnrc Thu Feb 21 14:28:13 1991
--- ./yacc.y.gnrc Thu Feb 21 14:28:22 1991
***************
*** 249,255 ****
--- 252,266 ----
if (!Pflag && *sysin)
printf ("# line %d \"%s\"\n",
$1 -> ya_lineno, sysin);
+ %BEGIN(PEPY)%
+ pepy_finalize ($1 -> ya_text, stdout);
+ %END(PEPY)%
+ %BEGIN(ROSY)%
fputs ($1 -> ya_text, stdout);
+ %END(ROSY)%
+ %BEGIN(MOSY)%
+ fputs ($1 -> ya_text, stdout);
+ %END(MOSY)%
}
else {
printf ("%%{\n#include \"%s-types.h\"\n",