5 Jul 14:06
bugs in FreeCOM
Arkady V.Belousov <ark <at> belous.munic.msk.su>
2004-07-05 12:06:20 GMT
2004-07-05 12:06:20 GMT
Hi!
1. FreeCOM incorrectly handles empty environment, _as this understanded by
MS-DOS_. Trouble is that for empty environment MS-DOS places before
16-bit counter not _one_, but _two_ zero bytes. This is easy to see: make
empty config.sys with line INSTALL=FREECOM.COM and FreeCOM will not
detect presence of path after environment.
Solution (accept right variant and as MS-DOS):
/* env_seg != 0 */
const char FAR *p = MK_SEG_PTR (const char, env_seg);
while (*p) /* find end of environment */
p += fstrlen (p) + 1; /* skip next variable */
if (FP_OFF (p) == 0) /* empty enviroment? */
{
/* by definition empty enviornment should be
"\0\1\0<path>\0", but MS-DOS make one more zero:
"\0\0\1\0<path>\0"; accept both variants
*/
if (*(const word FAR*)p == 0) /* two zero bytes? */
p++; /* skip one */
}
2. For empty config.sys with line SHELL=FREECOM.COM MS-DOS calls FreeCOM
with PSP.ps_environ=0. This cause that FreeCOM not finds itself for
strings resources. This is not bug, but unconvenient.
Solution: before saying error message (when no environment, path not
found after environment or path is wrong), FreeCOM should (like MS-DOS)
try to find itself on boot drive (INT21/3305) with names like
"\command.com", "\fdos\command.com", "\freedos\command.com" and
"\dos\command.com". Also this search loop may be repeated with
"freecom.com" name.
3. If FreeCOM doesn't finds own (startup) path (no environment or wrongly
handled empty environment), then (with option /p) it just exits (with
message, that path should be pointed as first argument) or (without /p)
it asks to enter path (but should try to find itself, as in (2), then
asks _name with path_). Also, after asking path, if FreeCOM anyway not
finds itself (for example, command.com rename into other name), it again
exits.
-------------------------------------------------------
This SF.Net email sponsored by Black Hat Briefings & Training.
Attend Black Hat Briefings & Training, Las Vegas July 24-29 -
digital self defense, top technical experts, no vendor pitches,
unmatched networking opportunities. Visit www.blackhat.com
RSS Feed