diff --git a/server/main.c b/server/main.c index 7c5f82d..eb7958c 100644 --- a/server/main.c +++ b/server/main.c @@ -310,9 +310,14 @@ process_command_line(int argc, char **argv) case 'd': /* Add to a list of drivers to be initialized later...*/ if (num_drivers < MAX_DRIVERS) { - drivernames[num_drivers] = malloc( strlen(optarg)+1 ); - strcpy( drivernames[num_drivers], optarg ); - num_drivers ++; + drivernames[num_drivers] = strdup(optarg); + if (drivernames[num_drivers] != NULL) { + num_drivers ++; + } + else { + report(RPT_ERR, "alloc error storing driver name: %s", optarg); + e = -1 + } } else { report( RPT_ERR, "Too many drivers!" ); e = -1; diff --git a/shared/sockets.c b/shared/sockets.c index d36ea33..ff022b1 100644 --- a/shared/sockets.c +++ b/shared/sockets.c @@ -315,7 +315,7 @@ sock_printf_error(int fd, const char *format, .../*args*/ ) va_list ap; int size = 0; - strcpy(buf, huh); + strncpy(buf, huh, sizeof(huh)); // note: sizeof(huh) < MAXMSG va_start(ap, format); size = vsnprintf(buf + (sizeof(huh)-1), sizeof(buf) - (sizeof(huh)-1), format, ap);