sprintf(logbuf, "client:\tSB TSPEED IS %s", cfg.termspeed);
logbuf = dupprintf("client:\tSB TSPEED IS %s", cfg.termspeed);
static void process_subneg(Telnet telnet){    unsigned char b[2048], *p, *q;    int var, value, n;    char *e;    switch (telnet->sb_opt) {      case TELOPT_TSPEED:	if (telnet->sb_len == 1 && telnet->sb_buf[0] == TELQUAL_SEND) {	    char logbuf[sizeof(cfg.termspeed) + 80];	    b[0] = IAC;	    b[1] = SB;	    b[2] = TELOPT_TSPEED;	    b[3] = TELQUAL_IS;	    strcpy(b + 4, cfg.termspeed);	    n = 4 + strlen(cfg.termspeed);	    b[n] = IAC;	    b[n + 1] = SE;	    telnet->bufsize = sk_write(telnet->s, b, n + 2);	    logevent(telnet->frontend, "server:\tSB TSPEED SEND");	    sprintf(logbuf, "client:\tSB TSPEED IS %s", cfg.termspeed);	    logevent(telnet->frontend, logbuf);	} else	    logevent(telnet->frontend, "server:\tSB TSPEED <something weird>");	break;      case TELOPT_TTYPE:	if (telnet->sb_len == 1 && telnet->sb_buf[0] == TELQUAL_SEND) {	    char logbuf[sizeof(cfg.termtype) + 80];	    b[0] = IAC;	    b[1] = SB;	    b[2] = TELOPT_TTYPE;	    b[3] = TELQUAL_IS;	    for (n = 0; cfg.termtype[n]; n++)		b[n + 4] = (cfg.termtype[n] >= 'a'			    && cfg.termtype[n] <=			    'z' ? cfg.termtype[n] + 'A' -			    'a' : cfg.termtype[n]);	    b[n + 4] = IAC;	    b[n + 5] = SE;	    telnet->bufsize = sk_write(telnet->s, b, n + 6);	    b[n + 4] = 0;	    logevent(telnet->frontend, "server:\tSB TTYPE SEND");	    sprintf(logbuf, "client:\tSB TTYPE IS %s", b + 4);	    logevent(telnet->frontend, logbuf);	} else	    logevent(telnet->frontend, "server:\tSB TTYPE <something weird>\r\n");	break;      case TELOPT_OLD_ENVIRON:      case TELOPT_NEW_ENVIRON:	p = telnet->sb_buf;	q = p + telnet->sb_len;	if (p < q && *p == TELQUAL_SEND) {	    char logbuf[50];	    p++;	    sprintf(logbuf, "server:\tSB %s SEND", telopt(telnet->sb_opt));	    logevent(telnet->frontend, logbuf);	    if (telnet->sb_opt == TELOPT_OLD_ENVIRON) {		if (cfg.rfc_environ) {		    value = RFC_VALUE;		    var = RFC_VAR;		} else {		    value = BSD_VALUE;		    var = BSD_VAR;		}		/*		 * Try to guess the sense of VAR and VALUE.		 */		while (p < q) {		    if (*p == RFC_VAR) {			value = RFC_VALUE;			var = RFC_VAR;		    } else if (*p == BSD_VAR) {			value = BSD_VALUE;			var = BSD_VAR;		    }		    p++;		}	    } else {		/*		 * With NEW_ENVIRON, the sense of VAR and VALUE		 * isn't in doubt.		 */		value = RFC_VALUE;		var = RFC_VAR;	    }	    b[0] = IAC;	    b[1] = SB;	    b[2] = telnet->sb_opt;	    b[3] = TELQUAL_IS;	    n = 4;	    e = cfg.environmt;	    while (*e) {		b[n++] = var;		while (*e && *e != '\t')		    b[n++] = *e++;		if (*e == '\t')		    e++;		b[n++] = value;		while (*e)		    b[n++] = *e++;		e++;	    }	    if (*cfg.username) {		b[n++] = var;		b[n++] = 'U';		b[n++] = 'S';		b[n++] = 'E';		b[n++] = 'R';		b[n++] = value;		e = cfg.username;		while (*e)		    b[n++] = *e++;	    }	    b[n++] = IAC;	    b[n++] = SE;	    telnet->bufsize = sk_write(telnet->s, b, n);	    sprintf(logbuf, "client:\tSB %s IS %s", telopt(telnet->sb_opt),		    n == 6 ? "<nothing>" : "<stuff>");	    logevent(telnet->frontend, logbuf);	}	break;    }}