Module Name: src Committed By: kre Date: Tue Apr 30 20:56:32 UTC 2019
Modified Files: src/sys/net: dl_print.c Log Message: Add the missing add. (Return to the earlier state, done differently.) When dl_print() was converted to use lla_snprintf() the offset to the LLA in dl_addr.dl_data was forgotten (dl_data contains both the interface name and the LL addr, we want the latter, not the former). When there is no data (src_len == 0), still null terminate the output buffer (provided there is space in it for the \0). To generate a diff of this commit: cvs rdiff -u -r1.5 -r1.6 src/sys/net/dl_print.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/net/dl_print.c diff -u src/sys/net/dl_print.c:1.5 src/sys/net/dl_print.c:1.6 --- src/sys/net/dl_print.c:1.5 Mon Apr 29 19:08:11 2019 +++ src/sys/net/dl_print.c Tue Apr 30 20:56:32 2019 @@ -1,4 +1,4 @@ -/* $NetBSD: dl_print.c,v 1.5 2019/04/29 19:08:11 christos Exp $ */ +/* $NetBSD: dl_print.c,v 1.6 2019/04/30 20:56:32 kre Exp $ */ /*- * Copyright (c) 2014 The NetBSD Foundation, Inc. @@ -29,10 +29,10 @@ #include <sys/types.h> #ifdef _KERNEL -__KERNEL_RCSID(0, "$NetBSD: dl_print.c,v 1.5 2019/04/29 19:08:11 christos Exp $"); +__KERNEL_RCSID(0, "$NetBSD: dl_print.c,v 1.6 2019/04/30 20:56:32 kre Exp $"); #include <sys/systm.h> #else -__RCSID("$NetBSD: dl_print.c,v 1.5 2019/04/29 19:08:11 christos Exp $"); +__RCSID("$NetBSD: dl_print.c,v 1.6 2019/04/30 20:56:32 kre Exp $"); #include <stdio.h> static const char hexdigits[] = "0123456789abcdef"; #endif @@ -44,8 +44,11 @@ lla_snprintf(char *dst, size_t dst_len, char *dp; const uint8_t *sp, *ep; - if (src_len == 0 || dst_len < 3) + if (src_len == 0 || dst_len < 3) { + if (dst_len != 0) + dst[0] = '\0'; return NULL; + } dp = dst; sp = (const uint8_t *)src; @@ -68,7 +71,7 @@ dl_print(char *buf, size_t len, const st { char abuf[256 * 3]; - lla_snprintf(abuf, sizeof(abuf), dl->dl_data, dl->dl_alen); + lla_snprintf(abuf, sizeof(abuf), dl->dl_data+dl->dl_nlen, dl->dl_alen); return snprintf(buf, len, "%.*s/%hhu#%s", (int)dl->dl_nlen, dl->dl_data, dl->dl_type, abuf); }