mirror of
https://github.com/anrieff/libcpuid
synced 2025-06-07 00:51:40 +00:00
cpuid_tool: replace strcpy() by strncpy()
Warning on OpenBSD: warning: strcpy() is almost always misused, please use strlcpy()
This commit is contained in:
parent
4ca6174e70
commit
447bc0d8d9
1 changed files with 9 additions and 7 deletions
|
@ -54,8 +54,10 @@
|
||||||
#include "libcpuid.h"
|
#include "libcpuid.h"
|
||||||
|
|
||||||
/* Globals: */
|
/* Globals: */
|
||||||
char raw_data_file[256] = "";
|
#define RAW_DATA_FILE_MAX 256
|
||||||
char out_file[256] = "";
|
#define OUT_FILE_MAX 256
|
||||||
|
char raw_data_file[RAW_DATA_FILE_MAX] = "";
|
||||||
|
char out_file[OUT_FILE_MAX] = "";
|
||||||
typedef enum {
|
typedef enum {
|
||||||
NEED_CPUID_PRESENT,
|
NEED_CPUID_PRESENT,
|
||||||
NEED_ARCHITECTURE,
|
NEED_ARCHITECTURE,
|
||||||
|
@ -237,8 +239,8 @@ static int parse_cmdline(int argc, char** argv)
|
||||||
if (argc == 1) {
|
if (argc == 1) {
|
||||||
/* Default command line options */
|
/* Default command line options */
|
||||||
need_output = 1;
|
need_output = 1;
|
||||||
strcpy(raw_data_file, "raw.txt");
|
strncpy(raw_data_file, "raw.txt", RAW_DATA_FILE_MAX);
|
||||||
strcpy(out_file, "report.txt");
|
strncpy(out_file, "report.txt", OUT_FILE_MAX);
|
||||||
need_report = 1;
|
need_report = 1;
|
||||||
verbose_level = 1;
|
verbose_level = 1;
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -261,7 +263,7 @@ static int parse_cmdline(int argc, char** argv)
|
||||||
xerror("--load: bad file specification!");
|
xerror("--load: bad file specification!");
|
||||||
}
|
}
|
||||||
need_input = 1;
|
need_input = 1;
|
||||||
strcpy(raw_data_file, arg + 7);
|
strncpy(raw_data_file, arg + 7, RAW_DATA_FILE_MAX);
|
||||||
recog = 1;
|
recog = 1;
|
||||||
}
|
}
|
||||||
if (!strncmp(arg, "--save=", 7)) {
|
if (!strncmp(arg, "--save=", 7)) {
|
||||||
|
@ -275,14 +277,14 @@ static int parse_cmdline(int argc, char** argv)
|
||||||
xerror("--save: bad file specification!");
|
xerror("--save: bad file specification!");
|
||||||
}
|
}
|
||||||
need_output = 1;
|
need_output = 1;
|
||||||
strcpy(raw_data_file, arg + 7);
|
strncpy(raw_data_file, arg + 7, RAW_DATA_FILE_MAX);
|
||||||
recog = 1;
|
recog = 1;
|
||||||
}
|
}
|
||||||
if (!strncmp(arg, "--outfile=", 10)) {
|
if (!strncmp(arg, "--outfile=", 10)) {
|
||||||
if (strlen(arg) <= 10) {
|
if (strlen(arg) <= 10) {
|
||||||
xerror("--output: bad file specification!");
|
xerror("--output: bad file specification!");
|
||||||
}
|
}
|
||||||
strcpy(out_file, arg + 10);
|
strncpy(out_file, arg + 10, RAW_DATA_FILE_MAX);
|
||||||
recog = 1;
|
recog = 1;
|
||||||
}
|
}
|
||||||
if (!strcmp(arg, "--report") || !strcmp(arg, "--all")) {
|
if (!strcmp(arg, "--report") || !strcmp(arg, "--all")) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue