Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!watmath!clyde!burl!ulysses!mhuxr!mhuxn!ihnp4!qantel!lll-lcc!lll-crg!seismo!elsie!ado From: ado@elsie.UUCP (Arthur David Olson) Newsgroups: net.bugs.4bsd Subject: 4.[123]bsd stty command gives garbage for exotic speed codes (with fix) Message-ID: <6087@elsie.UUCP> Date: Tue, 29-Apr-86 16:07:43 EDT Article-I.D.: elsie.6087 Posted: Tue Apr 29 16:07:43 1986 Date-Received: Fri, 2-May-86 23:36:49 EDT Organization: NIH-LEC, Bethesda, MD Lines: 52 Keywords: bsd stty speed Index: bin/stty.c Fix Description: The stty command gives wild output for speed values outside the range it knows about. Repeat-By: Compile this source into a.out: # #include "sgtty.h" main(argc, argv) int argc; char * argv[]; { struct sgttyb old, new; gtty(0, &old); new = old; new.sg_ispeed = new.sg_ospeed = atoi(argv[1]); stty(0, &new); (void) system("stty 2>&1 1>&0"); stty(0, &old); return 0; } then type in the command a.out 20 > results ; cat results and note the "speed" portion of the output: . . .speed 1701707883 baud; . . . Fix: The fix is to stty.c, in particular to the function prspeed. The changes are shown below, conditioned on OLDVERSION. As usual, the trade secret status of the code involved precludes a clearer posting. prspeed(c, s) char *c; { #ifdef OLDVERSION fprintf(stderr,"%s%d baud", c, speed[s]); #else if (s < 0 || s >= sizeof speed / sizeof speed[0]) (void) fprintf(stderr, "%scode %d", c, s); else (void) fprintf(stderr, "%s%d baud", c, speed[s]); #endif OLDVERSION } -- UUCP: ..decvax!seismo!elsie!ado ARPA: elsie!ado@seismo.ARPA DEC, VAX, Elsie & Ado are Digital, Borden & Shakespeare trademarks.