summaryrefslogtreecommitdiffstats
path: root/usr.sbin/ppp
diff options
context:
space:
mode:
authorbrian <brian@FreeBSD.org>2009-08-24 17:18:17 +0000
committerbrian <brian@FreeBSD.org>2009-08-24 17:18:17 +0000
commit713a988257803198210ed1fa32fb351909facd52 (patch)
treeaf7b4b6a810ab2e555809c5f8d6db2c6b3fe1604 /usr.sbin/ppp
parentba7b3afabc9c18fbc00ee2b3a04d75cc7bf6f923 (diff)
downloadFreeBSD-src-713a988257803198210ed1fa32fb351909facd52.zip
FreeBSD-src-713a988257803198210ed1fa32fb351909facd52.tar.gz
When realloc()ing device memory for transfer to another ppp process,
don't continue to use the realloc()d pointer - it might have changed! Remove some stray diagnostics while I'm here. MFC after: 3 days
Diffstat (limited to 'usr.sbin/ppp')
-rw-r--r--usr.sbin/ppp/ether.c7
-rw-r--r--usr.sbin/ppp/netgraph.c8
-rw-r--r--usr.sbin/ppp/tty.c9
3 files changed, 13 insertions, 11 deletions
diff --git a/usr.sbin/ppp/ether.c b/usr.sbin/ppp/ether.c
index e4e154a..a86f3bd 100644
--- a/usr.sbin/ppp/ether.c
+++ b/usr.sbin/ppp/ether.c
@@ -193,17 +193,18 @@ static void
ether_device2iov(struct device *d, struct iovec *iov, int *niov,
int maxiov __unused, int *auxfd, int *nauxfd)
{
- struct etherdevice *dev = device2ether(d);
+ struct etherdevice *dev;
int sz = physical_MaxDeviceSize();
- iov[*niov].iov_base = realloc(d, sz);
- if (iov[*niov].iov_base == NULL) {
+ iov[*niov].iov_base = d = realloc(d, sz);
+ if (d == NULL) {
log_Printf(LogALERT, "Failed to allocate memory: %d\n", sz);
AbortProgram(EX_OSERR);
}
iov[*niov].iov_len = sz;
(*niov)++;
+ dev = device2ether(d);
if (dev->cs >= 0) {
*auxfd = dev->cs;
(*nauxfd)++;
diff --git a/usr.sbin/ppp/netgraph.c b/usr.sbin/ppp/netgraph.c
index 471dc0d..23a575b 100644
--- a/usr.sbin/ppp/netgraph.c
+++ b/usr.sbin/ppp/netgraph.c
@@ -235,7 +235,6 @@ ng_Read(struct physical *p, void *v, size_t n)
{
char hook[NG_HOOKSIZ];
-log_Printf(LogDEBUG, "ng_Read\n");
switch (p->dl->state) {
case DATALINK_DIAL:
case DATALINK_LOGIN:
@@ -282,17 +281,18 @@ static void
ng_device2iov(struct device *d, struct iovec *iov, int *niov,
int maxiov __unused, int *auxfd, int *nauxfd)
{
- struct ngdevice *dev = device2ng(d);
+ struct ngdevice *dev;
int sz = physical_MaxDeviceSize();
- iov[*niov].iov_base = realloc(d, sz);
- if (iov[*niov].iov_base == NULL) {
+ iov[*niov].iov_base = d = realloc(d, sz);
+ if (d == NULL) {
log_Printf(LogALERT, "Failed to allocate memory: %d\n", sz);
AbortProgram(EX_OSERR);
}
iov[*niov].iov_len = sz;
(*niov)++;
+ dev = device2ng(d);
*auxfd = dev->cs;
(*nauxfd)++;
}
diff --git a/usr.sbin/ppp/tty.c b/usr.sbin/ppp/tty.c
index 8d5d58b..ab984cc 100644
--- a/usr.sbin/ppp/tty.c
+++ b/usr.sbin/ppp/tty.c
@@ -384,7 +384,6 @@ UnloadLineDiscipline(struct physical *p)
struct ttydevice *dev = device2tty(p->handler);
if (isngtty(dev)) {
-log_Printf(LogPHASE, "back to speed %d\n", dev->real.speed);
if (!physical_SetSpeed(p, dev->real.speed))
log_Printf(LogWARN, "Couldn't reset tty speed to %d\n", dev->real.speed);
dev->real.speed = 0;
@@ -582,17 +581,19 @@ tty_device2iov(struct device *d, struct iovec *iov, int *niov,
#endif
)
{
- struct ttydevice *dev = device2tty(d);
+ struct ttydevice *dev;
int sz = physical_MaxDeviceSize();
- iov[*niov].iov_base = realloc(d, sz);
- if (iov[*niov].iov_base == NULL) {
+ iov[*niov].iov_base = d = realloc(d, sz);
+ if (d == NULL) {
log_Printf(LogALERT, "Failed to allocate memory: %d\n", sz);
AbortProgram(EX_OSERR);
}
iov[*niov].iov_len = sz;
(*niov)++;
+ dev = device2tty(d);
+
#ifndef NONETGRAPH
if (dev->cs >= 0) {
*auxfd = dev->cs;
OpenPOWER on IntegriCloud