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
This commit is contained in:
parent
89ffc202d6
commit
c5e246d446
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=196513
@ -193,17 +193,18 @@ static void
|
|||||||
ether_device2iov(struct device *d, struct iovec *iov, int *niov,
|
ether_device2iov(struct device *d, struct iovec *iov, int *niov,
|
||||||
int maxiov __unused, int *auxfd, int *nauxfd)
|
int maxiov __unused, int *auxfd, int *nauxfd)
|
||||||
{
|
{
|
||||||
struct etherdevice *dev = device2ether(d);
|
struct etherdevice *dev;
|
||||||
int sz = physical_MaxDeviceSize();
|
int sz = physical_MaxDeviceSize();
|
||||||
|
|
||||||
iov[*niov].iov_base = realloc(d, sz);
|
iov[*niov].iov_base = d = realloc(d, sz);
|
||||||
if (iov[*niov].iov_base == NULL) {
|
if (d == NULL) {
|
||||||
log_Printf(LogALERT, "Failed to allocate memory: %d\n", sz);
|
log_Printf(LogALERT, "Failed to allocate memory: %d\n", sz);
|
||||||
AbortProgram(EX_OSERR);
|
AbortProgram(EX_OSERR);
|
||||||
}
|
}
|
||||||
iov[*niov].iov_len = sz;
|
iov[*niov].iov_len = sz;
|
||||||
(*niov)++;
|
(*niov)++;
|
||||||
|
|
||||||
|
dev = device2ether(d);
|
||||||
if (dev->cs >= 0) {
|
if (dev->cs >= 0) {
|
||||||
*auxfd = dev->cs;
|
*auxfd = dev->cs;
|
||||||
(*nauxfd)++;
|
(*nauxfd)++;
|
||||||
|
@ -235,7 +235,6 @@ ng_Read(struct physical *p, void *v, size_t n)
|
|||||||
{
|
{
|
||||||
char hook[NG_HOOKSIZ];
|
char hook[NG_HOOKSIZ];
|
||||||
|
|
||||||
log_Printf(LogDEBUG, "ng_Read\n");
|
|
||||||
switch (p->dl->state) {
|
switch (p->dl->state) {
|
||||||
case DATALINK_DIAL:
|
case DATALINK_DIAL:
|
||||||
case DATALINK_LOGIN:
|
case DATALINK_LOGIN:
|
||||||
@ -282,17 +281,18 @@ static void
|
|||||||
ng_device2iov(struct device *d, struct iovec *iov, int *niov,
|
ng_device2iov(struct device *d, struct iovec *iov, int *niov,
|
||||||
int maxiov __unused, int *auxfd, int *nauxfd)
|
int maxiov __unused, int *auxfd, int *nauxfd)
|
||||||
{
|
{
|
||||||
struct ngdevice *dev = device2ng(d);
|
struct ngdevice *dev;
|
||||||
int sz = physical_MaxDeviceSize();
|
int sz = physical_MaxDeviceSize();
|
||||||
|
|
||||||
iov[*niov].iov_base = realloc(d, sz);
|
iov[*niov].iov_base = d = realloc(d, sz);
|
||||||
if (iov[*niov].iov_base == NULL) {
|
if (d == NULL) {
|
||||||
log_Printf(LogALERT, "Failed to allocate memory: %d\n", sz);
|
log_Printf(LogALERT, "Failed to allocate memory: %d\n", sz);
|
||||||
AbortProgram(EX_OSERR);
|
AbortProgram(EX_OSERR);
|
||||||
}
|
}
|
||||||
iov[*niov].iov_len = sz;
|
iov[*niov].iov_len = sz;
|
||||||
(*niov)++;
|
(*niov)++;
|
||||||
|
|
||||||
|
dev = device2ng(d);
|
||||||
*auxfd = dev->cs;
|
*auxfd = dev->cs;
|
||||||
(*nauxfd)++;
|
(*nauxfd)++;
|
||||||
}
|
}
|
||||||
|
@ -384,7 +384,6 @@ UnloadLineDiscipline(struct physical *p)
|
|||||||
struct ttydevice *dev = device2tty(p->handler);
|
struct ttydevice *dev = device2tty(p->handler);
|
||||||
|
|
||||||
if (isngtty(dev)) {
|
if (isngtty(dev)) {
|
||||||
log_Printf(LogPHASE, "back to speed %d\n", dev->real.speed);
|
|
||||||
if (!physical_SetSpeed(p, dev->real.speed))
|
if (!physical_SetSpeed(p, dev->real.speed))
|
||||||
log_Printf(LogWARN, "Couldn't reset tty speed to %d\n", dev->real.speed);
|
log_Printf(LogWARN, "Couldn't reset tty speed to %d\n", dev->real.speed);
|
||||||
dev->real.speed = 0;
|
dev->real.speed = 0;
|
||||||
@ -582,17 +581,19 @@ tty_device2iov(struct device *d, struct iovec *iov, int *niov,
|
|||||||
#endif
|
#endif
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
struct ttydevice *dev = device2tty(d);
|
struct ttydevice *dev;
|
||||||
int sz = physical_MaxDeviceSize();
|
int sz = physical_MaxDeviceSize();
|
||||||
|
|
||||||
iov[*niov].iov_base = realloc(d, sz);
|
iov[*niov].iov_base = d = realloc(d, sz);
|
||||||
if (iov[*niov].iov_base == NULL) {
|
if (d == NULL) {
|
||||||
log_Printf(LogALERT, "Failed to allocate memory: %d\n", sz);
|
log_Printf(LogALERT, "Failed to allocate memory: %d\n", sz);
|
||||||
AbortProgram(EX_OSERR);
|
AbortProgram(EX_OSERR);
|
||||||
}
|
}
|
||||||
iov[*niov].iov_len = sz;
|
iov[*niov].iov_len = sz;
|
||||||
(*niov)++;
|
(*niov)++;
|
||||||
|
|
||||||
|
dev = device2tty(d);
|
||||||
|
|
||||||
#ifndef NONETGRAPH
|
#ifndef NONETGRAPH
|
||||||
if (dev->cs >= 0) {
|
if (dev->cs >= 0) {
|
||||||
*auxfd = dev->cs;
|
*auxfd = dev->cs;
|
||||||
|
Loading…
Reference in New Issue
Block a user