Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/net safely extract character sequences from packet for p...
details: https://anonhg.NetBSD.org/src/rev/e24f7c865a23
branches: trunk
changeset: 744708:e24f7c865a23
user: mlelstv <mlelstv%NetBSD.org@localhost>
date: Mon Feb 10 22:38:10 2020 +0000
description:
safely extract character sequences from packet for printing.
diffstat:
sys/net/if_pppoe.c | 20 +++++++++++++-------
1 files changed, 13 insertions(+), 7 deletions(-)
diffs (68 lines):
diff -r 200527678b1f -r e24f7c865a23 sys/net/if_pppoe.c
--- a/sys/net/if_pppoe.c Mon Feb 10 22:33:28 2020 +0000
+++ b/sys/net/if_pppoe.c Mon Feb 10 22:38:10 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: if_pppoe.c,v 1.148 2020/01/29 04:28:27 thorpej Exp $ */
+/* $NetBSD: if_pppoe.c,v 1.149 2020/02/10 22:38:10 mlelstv Exp $ */
/*
* Copyright (c) 2002, 2008 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_pppoe.c,v 1.148 2020/01/29 04:28:27 thorpej Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_pppoe.c,v 1.149 2020/02/10 22:38:10 mlelstv Exp $");
#ifdef _KERNEL_OPT
#include "pppoe.h"
@@ -558,6 +558,7 @@
const char *err_msg;
char devname[IF_NAMESIZE];
char *error;
+ size_t dlen;
uint8_t *ac_cookie;
size_t ac_cookie_len;
uint8_t *relay_sid;
@@ -631,7 +632,8 @@
break; /* ignored */
case PPPOE_TAG_ACNAME:
if (len > 0) {
- error = malloc(len + 1, M_TEMP, M_NOWAIT);
+ dlen = 4 * len + 1;
+ error = malloc(dlen, M_TEMP, M_NOWAIT);
if (error == NULL)
break;
@@ -643,7 +645,9 @@
goto done;
}
- strlcpy(error, mtod(n, char*) + noff, len + 1);
+ strnvisx(error, dlen,
+ mtod(n, char*) + noff, len,
+ VIS_SAFE | VIS_OCTAL);
printf("pppoe: connected to %s\n", error);
free(error, M_TEMP);
}
@@ -704,15 +708,17 @@
if (err_msg) {
error = NULL;
if (errortag && len) {
- error = malloc(len + 1, M_TEMP,
+ dlen = 4 * len + 1;
+ error = malloc(dlen, M_TEMP,
M_NOWAIT|M_ZERO);
n = m_pulldown(m, off + sizeof(*pt), len,
&noff);
if (!n) {
m = NULL;
} else if (error) {
- strlcpy(error, mtod(n, char *) + noff,
- len + 1);
+ strnvisx(error, dlen,
+ mtod(n, char*) + noff, len,
+ VIS_SAFE | VIS_OCTAL);
}
}
if (error) {
Home |
Main Index |
Thread Index |
Old Index