2005-01-31 Sergei Organov <osv@topconrd.ru>

PR 771/pppd
	* libnetworking/pppd/chat.c, libnetworking/pppd/rtemsmain.c: The fix
	committed to fix PR736 breaks pppd. chat.c should have its own static
	ttyfd for pppd to work correctly. The symptom is that second
	invokation of chat (for connect script) fails due to pppd_ttyfd set
	to -1 by previous chat invokation (for init script). In addition,
	this patch fixes leaving of dangling pointer in the abort_stbring[]
	by chat_send().
This commit is contained in:
Joel Sherrill
2005-01-31 22:21:19 +00:00
parent fa5dfe8f35
commit 9c858e562f
5 changed files with 43 additions and 32 deletions

View File

@@ -1,3 +1,14 @@
2005-01-31 Sergei Organov <osv@topconrd.ru>
PR 771/pppd
* libnetworking/pppd/chat.c, libnetworking/pppd/rtemsmain.c: The fix
committed to fix PR736 breaks pppd. chat.c should have its own static
ttyfd for pppd to work correctly. The symptom is that second
invokation of chat (for connect script) fails due to pppd_ttyfd set
to -1 by previous chat invokation (for init script). In addition,
this patch fixes leaving of dangling pointer in the abort_stbring[]
by chat_send().
2005-01-24 Ralf Corsepius <ralf.corsepius@rtems.org>
* configure.ac: Remove CFLAGS_DEBUG_V.

View File

@@ -163,7 +163,7 @@ static int use_env = 0;
static int exit_code = 0;
static char *phone_num = (char *) 0;
static char *phone_num2 = (char *) 0;
/* static */ int pppd_ttyfd;
static int ttyfd;
static int timeout = DEFAULT_CHAT_TIMEOUT;
#ifdef TERMIOS
@@ -246,7 +246,7 @@ int chatmain(int fd, int mode, char *pScript)
/* initialize exit code */
exit_code = 0;
pppd_ttyfd = fd;
ttyfd = fd;
script=pScript;
@@ -271,14 +271,14 @@ int chatmain(int fd, int mode, char *pScript)
}
}
}
pppd_ttyfd = (int)-1;
ttyfd = (int)-1;
return ( exit_code );
}
void break_sequence()
{
tcsendbreak(pppd_ttyfd, 0);
tcsendbreak(ttyfd, 0);
}
/*
@@ -639,14 +639,13 @@ register char *s;
}
if (abort_next) {
char *s1;
abort_next = 0;
if ( n_aborts < MAX_ABORTS ) {
char *s1;
s1 = clean(s, 0);
if (( strlen(s1) <= strlen(s) ) && ( strlen(s1) < sizeof(fail_buffer))) {
if (( strlen(s1) <= strlen(s) ) && ( strlen(s1) < sizeof(fail_buffer)))
abort_string[n_aborts++] = s1;
}
else
free(s1);
}
return;
@@ -699,7 +698,7 @@ static int get_char()
while(tries)
{
status = read(pppd_ttyfd, &c, 1);
status = read(ttyfd, &c, 1);
switch (status) {
case 1:
return ((int)c & 0x7F);
@@ -715,7 +714,7 @@ int c;
{
char ch = c;
return(write(pppd_ttyfd, &ch, 1));
return(write(ttyfd, &ch, 1));
}
static int write_char (c)
@@ -791,10 +790,10 @@ register char *in_string;
memset(temp2, 0, sizeof(temp2));
tcgetattr(pppd_ttyfd, &tios);
tcgetattr(ttyfd, &tios);
tios.c_cc[VMIN] = 0;
tios.c_cc[VTIME] = timeout*10/MAX_TIMEOUTS;
tcsetattr(pppd_ttyfd, TCSANOW, &tios);
tcsetattr(ttyfd, TCSANOW, &tios);
string = clean(in_string, 0);
len = strlen(string);
@@ -807,6 +806,7 @@ register char *in_string;
}
if (len == 0) {
free(string);
return (1);
}

View File

@@ -77,7 +77,7 @@ int pppifunit; /* Interface unit number */
char hostname[MAXNAMELEN]; /* Our hostname */
static char ppp_devnam[MAXPATHLEN]; /* name of PPP tty (maybe ttypx) */
/* int pppd_ttyfd; * Serial port file descriptor */
int pppd_ttyfd; /* Serial port file descriptor */
int baud_rate; /* Actual bits/second for serial device */
int hungup; /* terminal has been hung up */
int privileged; /* we're running as real uid root */

View File

@@ -163,7 +163,7 @@ static int use_env = 0;
static int exit_code = 0;
static char *phone_num = (char *) 0;
static char *phone_num2 = (char *) 0;
/* static */ int pppd_ttyfd;
static int ttyfd;
static int timeout = DEFAULT_CHAT_TIMEOUT;
#ifdef TERMIOS
@@ -246,7 +246,7 @@ int chatmain(int fd, int mode, char *pScript)
/* initialize exit code */
exit_code = 0;
pppd_ttyfd = fd;
ttyfd = fd;
script=pScript;
@@ -271,14 +271,14 @@ int chatmain(int fd, int mode, char *pScript)
}
}
}
pppd_ttyfd = (int)-1;
ttyfd = (int)-1;
return ( exit_code );
}
void break_sequence()
{
tcsendbreak(pppd_ttyfd, 0);
tcsendbreak(ttyfd, 0);
}
/*
@@ -639,14 +639,13 @@ register char *s;
}
if (abort_next) {
char *s1;
abort_next = 0;
if ( n_aborts < MAX_ABORTS ) {
char *s1;
s1 = clean(s, 0);
if (( strlen(s1) <= strlen(s) ) && ( strlen(s1) < sizeof(fail_buffer))) {
if (( strlen(s1) <= strlen(s) ) && ( strlen(s1) < sizeof(fail_buffer)))
abort_string[n_aborts++] = s1;
}
else
free(s1);
}
return;
@@ -699,7 +698,7 @@ static int get_char()
while(tries)
{
status = read(pppd_ttyfd, &c, 1);
status = read(ttyfd, &c, 1);
switch (status) {
case 1:
return ((int)c & 0x7F);
@@ -715,7 +714,7 @@ int c;
{
char ch = c;
return(write(pppd_ttyfd, &ch, 1));
return(write(ttyfd, &ch, 1));
}
static int write_char (c)
@@ -791,10 +790,10 @@ register char *in_string;
memset(temp2, 0, sizeof(temp2));
tcgetattr(pppd_ttyfd, &tios);
tcgetattr(ttyfd, &tios);
tios.c_cc[VMIN] = 0;
tios.c_cc[VTIME] = timeout*10/MAX_TIMEOUTS;
tcsetattr(pppd_ttyfd, TCSANOW, &tios);
tcsetattr(ttyfd, TCSANOW, &tios);
string = clean(in_string, 0);
len = strlen(string);
@@ -807,6 +806,7 @@ register char *in_string;
}
if (len == 0) {
free(string);
return (1);
}

View File

@@ -77,7 +77,7 @@ int pppifunit; /* Interface unit number */
char hostname[MAXNAMELEN]; /* Our hostname */
static char ppp_devnam[MAXPATHLEN]; /* name of PPP tty (maybe ttypx) */
/* int pppd_ttyfd; * Serial port file descriptor */
int pppd_ttyfd; /* Serial port file descriptor */
int baud_rate; /* Actual bits/second for serial device */
int hungup; /* terminal has been hung up */
int privileged; /* we're running as real uid root */