diff --git a/src/conf.c b/src/conf.c index 89b979a..5c86fcb 100644 --- a/src/conf.c +++ b/src/conf.c @@ -132,7 +132,7 @@ int pusb_conf_init(t_pusb_options *opts) log_error("uname: %s\n", strerror(errno)); return (0); } - strncpy(opts->hostname, u.nodename, sizeof(opts->hostname)); + strncpy(opts->hostname, u.nodename, sizeof(opts->hostname) - 1); if (strlen(u.nodename) > sizeof(opts->hostname)) log_info("Hostname \"%s\" is too long, truncating to \"%s\".\n", u.nodename, opts->hostname); diff --git a/src/conf.h b/src/conf.h index d2dae23..9c635c2 100644 --- a/src/conf.h +++ b/src/conf.h @@ -47,7 +47,7 @@ typedef struct pusb_options int color_log; int one_time_pad; time_t pad_expiration; - char hostname[32]; + char hostname[64]; char system_pad_directory[PATH_MAX]; char device_pad_directory[PATH_MAX]; t_pusb_device device; diff --git a/src/local.c b/src/local.c index b085f49..42bc2d1 100644 --- a/src/local.c +++ b/src/local.c @@ -39,7 +39,7 @@ int pusb_local_login(t_pusb_options *opts, const char *user) if (!strncmp(from, "/dev/", strlen("/dev/"))) from += strlen("/dev/"); log_debug("Authentication request from tty %s\n", from); - strncpy(utsearch.ut_line, from, sizeof(utsearch.ut_line)); + strncpy(utsearch.ut_line, from, sizeof(utsearch.ut_line) - 1); setutent(); utent = getutline(&utsearch); endutent();