Acbosgd.2206 net.bugs.4bsd utzoo!decvax!harpo!eagle!mhuxt!cbosg!cbosgd!mark Wed Apr 7 12:48:49 1982 vi encryption bug nailed From: mark (Mark Horton) The long outstanding bug that caused vi to mess up when editing encrypted files (the temp file would be unencrypted in spots, and the file as shown to you would be encrypted) has finally been nailed. Thanks to Ed Bradford who reproduced it for me. The problem was that the calls to routine blkio in ex_temp.c in routine synctmp were not encrypting the buffer before writing it out to the temp file. This bug is now fixed in vi version 3.8. If you edit encrypted files and want the fix now, I'm enclosing a diff -c. Mark *************** *** 283,288 register int cnt; register line *a; register short *bp; #ifdef VMUNIX if (stilinc) --- 283,290 ----- register int cnt; register line *a; register short *bp; + register char *p1, *p2; + register int n; #ifdef VMUNIX if (stilinc) *************** *** 290,295 #endif if (dol == zero) return; if (ichanged) blkio(iblock, ibuff, write); ichanged = 0; --- 292,303 ----- #endif if (dol == zero) return; + /* + * In theory, we need to encrypt iblock and iblock2 before writing + * them out, as well as oblock, but in practice ichanged and ichang2 + * can never be set, so this isn't really needed. Likewise, the + * code in getblock above for iblock+iblock2 isn't needed. + */ if (ichanged) blkio(iblock, ibuff, write); ichanged = 0; *************** *** 297,302 blkio(iblock2, ibuff2, write); ichang2 = 0; if (oblock != -1) blkio(oblock, obuff, write); time(&H.Time); uid = getuid(); --- 305,325 ----- blkio(iblock2, ibuff2, write); ichang2 = 0; if (oblock != -1) + #ifdef CRYPT + if(xtflag) { + /* + * Encrypt block before writing, so some devious + * person can't look at temp file while editing. + */ + p1 = obuff; + p2 = crbuf; + n = CRSIZE; + while(n--) + *p2++ = *p1++; + crblock(tperm, crbuf, CRSIZE, (long)0); + blkio(oblock, crbuf, write); + } else + #endif blkio(oblock, obuff, write); time(&H.Time); uid = getuid(); ----------------------------------------------------------------- gopher://quux.org/ conversion by John Goerzen of http://communication.ucsd.edu/A-News/ This Usenet Oldnews Archive article may be copied and distributed freely, provided: 1. There is no money collected for the text(s) of the articles. 2. The following notice remains appended to each copy: The Usenet Oldnews Archive: Compilation Copyright (C) 1981, 1996 Bruce Jones, Henry Spencer, David Wiseman.