Path: utzoo!utgpu!water!watmath!clyde!att-cb!osu-cis!tut.cis.ohio-state.edu!mailrus!ames!pasteur!agate!eris!doug From: doug@eris (Doug Merritt) Newsgroups: comp.sys.amiga Subject: Re: calling all gurus Message-ID: <8814@agate.BERKELEY.EDU> Date: 16 Apr 88 17:09:01 GMT References: <8804051628.AA27845@decwrl.dec.com| <3482@ece-csc.UUCP| <8190@oberon.USC.EDU| <3484@ece-csc.UUCP| <8214@oberon.USC.EDU> <2161@antique.UUCP> <8725@agate.BERKELEY.EDU> <2176@antique.UUCP> Sender: usenet@agate.BERKELEY.EDU Reply-To: doug@eris.UUCP (Doug Merritt) Organization: University of California, Berkeley Lines: 53 >In article <8725@agate.BERKELEY.EDU> doug@eris.UUCP (Doug Merritt) writes: >>In article <2161@antique.UUCP> cjp@vax135.UUCP (Charles Poirier) writes: >>> >>>An easy hack would be to just check that the length of the file looks right. >>No! Remember that we're about to be blessed with 1.3, which is known to >>have extensions to Preferences. They'll probably extend the length of the >>file to store this new stuff. Eric Cotton's commented that in 1.3 the length is the same due to earlier reserved space was interesting, but it could still change length in 1.4 (as Eric pointed out). >Wouldn't it be okay to assume "devs:system-configuration" as >a permanent filename containing a valid Preferences? Then just stat that >file and stat the one you want to SetPrefs from and compare their lengths. >If unequal, either refuse to do it (my choice) or maybe give a requestor to >proceed (in case devs:system-configuration is invalid for some reason). Well, it's probably the best you can do in regard to length. But that's still not desirable. Consider that it might force a disk-swap just for data validation of uncertain veracity. Of course, this might be ok as long as you turn off requesters before looking for "devs:system-configuration", and skip the check if the "devs:" directory is unmounted. Better yet would be to actually do validity checking on the fields themselves, as originally suggested. Remember the only reason that this troublesome point came up was to avoid the "trouble" of checking fields. It appears to me that it's actually *less* trouble! To digress: By far the *best* solution would be if *all* file types had recognizable markings, like magic numbers. I have some heuristics in "filetype" for recognizing Preference config files (including but not limited to length [sigh] ), and I've been disturbed for a long time by the necessity for heuristic kludges for this kind of thing. And developers are *constantly* inventing new kinds of binary files (e.g. AMnews gadgets, menus, etc) and numeric script files (e.g. graphic objects), but people almost never bother to give them identifying characteristics. Hey, would one little magic number hurt that much? Keith Doyle's Director is a notable exception; the binary film shows are marked by the magic number 'FILM' (uh-oh; DaSilva constants strike again!) BTW I tried out some heuristics for recognizing ARP commands, and it's difficult (doable but hard to avoid false positives). My older heuristic for BCPL commands is pretty effective, with a small false positive rate. This is in regard to a previous posting about REZ's mistakes on this subject. Doug Merritt doug@mica.berkeley.edu (ucbvax!mica!doug) or ucbvax!unisoft!certes!doug