don't modify command-line parameters

This commit is contained in:
jmcneill 2012-01-15 10:30:21 +00:00
parent a60846ba16
commit 54fbc97dfe
1 changed files with 12 additions and 12 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: machdep.c,v 1.51 2012/01/15 10:18:58 jmcneill Exp $ */ /* $NetBSD: machdep.c,v 1.52 2012/01/15 10:30:21 jmcneill Exp $ */
/*- /*-
* Copyright (c) 2011 Reinoud Zandijk <reinoud@netbsd.org> * Copyright (c) 2011 Reinoud Zandijk <reinoud@netbsd.org>
@ -37,7 +37,7 @@
#include "opt_memsize.h" #include "opt_memsize.h"
#include <sys/cdefs.h> #include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.51 2012/01/15 10:18:58 jmcneill Exp $"); __KERNEL_RCSID(0, "$NetBSD: machdep.c,v 1.52 2012/01/15 10:30:21 jmcneill Exp $");
#include <sys/types.h> #include <sys/types.h>
#include <sys/systm.h> #include <sys/systm.h>
@ -128,21 +128,21 @@ main(int argc, char *argv[])
if (strncmp(argv[i], "net=", strlen("net=")) == 0) { if (strncmp(argv[i], "net=", strlen("net=")) == 0) {
char *tap = argv[i] + strlen("net="); char *tap = argv[i] + strlen("net=");
char *mac = strchr(tap, ','); char *mac = strchr(tap, ',');
char *p = usermode_tap_devicebuf;
if (mac == NULL) { if (mac == NULL) {
printf("bad net= format\n"); printf("bad net= format\n");
return; return;
} }
*mac++ = '\0'; memset(usermode_tap_devicebuf, 0,
if (*tap != '/') sizeof(usermode_tap_devicebuf));
snprintf(usermode_tap_devicebuf, if (*tap != '/') {
sizeof(usermode_tap_devicebuf), memcpy(p, "/dev/", strlen("/dev/"));
"/dev/%s", tap); p += strlen("/dev/");
else }
snprintf(usermode_tap_devicebuf, for (; *tap != ','; p++, tap++)
sizeof(usermode_tap_devicebuf), *p = *tap;
"%s", tap);
usermode_tap_device = usermode_tap_devicebuf; usermode_tap_device = usermode_tap_devicebuf;
usermode_tap_eaddr = mac; usermode_tap_eaddr = mac + 1;
} else if (strncmp(argv[i], "audio=", } else if (strncmp(argv[i], "audio=",
strlen("audio=")) == 0) { strlen("audio=")) == 0) {
char *audio = argv[i] + strlen("audio="); char *audio = argv[i] + strlen("audio=");