Newsgroups: comp.windows.x Path: utzoo!sq!lee From: lee@sq.sq.com (Liam R. E. Quin) Subject: xterm bug in parsing -S option Message-ID: <1990Aug22.210424.18890@sq.sq.com> Organization: SoftQuad Inc. Date: Wed, 22 Aug 90 21:04:24 GMT Lines: 52 X11 R4 xterm has a -S option that takes the last two characters of a terminal name ("p3" for /dev/ttyp3, for example) and the number of a file descriptor, so you can do xterm -Sp312 to read from file descriptor 12 on /dev/ttyp3. It works unless the file descriptor is zero, in which case the test in the code seems to be incorrect. Here is a (totally unofficial and not tested) patch. I don't seem to be able to recompile xterm without remaking all of the libraries, or spending hours hacking the makefile to use -lX11 instead of ../../lib/X/X11 and so on, sorry. In any case it seems better to test the return value of sscanf() in the following code. Lee Directory: /usr/src/x/mit/clients/xterm *** main.c.orig Wed Aug 22 16:09:47 1990 --- main.c Wed Aug 22 16:13:11 1990 *************** *** 722,730 **** #endif /* TIOCCONS */ continue; case 'S': ! sscanf(*argv + 2, "%c%c%d", passedPty, passedPty+1, ! &am_slave); ! if (am_slave <= 0) Syntax(*argv); continue; #ifdef DEBUG case 'D': --- 722,731 ---- #endif /* TIOCCONS */ continue; case 'S': ! if (sscanf(*argv + 2, "%c%c%d", passedPty, passedPty+1, ! &am_slave) != 3) { ! Syntax(*argv); ! } continue; #ifdef DEBUG case 'D': -- Liam R. E. Quin, lee@sq.com, {utai,utzoo}!sq!lee, SoftQuad Inc., Toronto Nicholas: [...] The best/ Thing we can do is to make wherever we're lost in Look as much like home as we can. [Christopher Fry, The Lady's Not For Burning]