ref: 236a5fcadfeb27c1ffa2037db91486019f226d4f
parent: 5c21eca829380c28769f79beabb7cc51f1787f97
author: 9ferno <gophone2015@gmail.com>
date: Fri Oct 14 09:50:23 EDT 2022
cleanup service argument parsing
--- a/config.c
+++ b/config.c
@@ -58,7 +58,7 @@
if((config.root.dest[1] = atoll(tokens[++i])) == 0)
panic("mafs: %s initconfig(): invalid size\n", service);
}else if(strcmp(tokens[i], "service") == 0){
- strncpy(config.service, tokens[++i], Namelen);
+ snprint(config.service, Namelen,"%s", tokens[++i]);
if((nl=strchr(config.service, '\n')) != nil)
*nl = '\0';
}
--- a/mafs.c
+++ b/mafs.c
@@ -41,7 +41,7 @@
{
static char *nets[8];
int doream, stdio, netc;
- char buf[Namelen], *raw;
+ char buf[Namelen];
int pid, ctl, n;
progname = "mafs";
@@ -73,10 +73,7 @@
doream = 1;
/* fall through */
case 'n':
- raw = EARGF(usage());
- if((n=strlen(raw)) >= Namelen)
- panic("service name is longer than %d characters\n", Namelen);
- strncpy(service, raw, n);
+ snprint(service, Namelen, "%s", EARGF(usage()));
break;
case 's': stdio++; break;
case 'a':
@@ -115,7 +112,7 @@
*/
init(doream);
if(service[0] == '\0')
- strncpy(service, config.service, strlen(config.service));
+ snprint(service, Namelen, "%s", config.service);
start9p(nets, stdio);
/*