diff --git a/libcpuid/libcpuid.h b/libcpuid/libcpuid.h index a6f0bfb..3775972 100644 --- a/libcpuid/libcpuid.h +++ b/libcpuid/libcpuid.h @@ -469,7 +469,7 @@ struct cpu_id_t { * +--------+--------+-------+-------+-------+---------------------------------------+-----------------------+ * @endcode */ - char cpu_codename[64]; + char cpu_codename[CODENAME_STR_MAX]; /** SSE execution unit size (64 or 128; -1 if N/A) */ int32_t sse_size; diff --git a/libcpuid/libcpuid_constants.h b/libcpuid/libcpuid_constants.h index be5bc0e..a88a7d0 100644 --- a/libcpuid/libcpuid_constants.h +++ b/libcpuid/libcpuid_constants.h @@ -34,6 +34,7 @@ #define VENDOR_STR_MAX 16 #define BRAND_STR_MAX 64 +#define CODENAME_STR_MAX 64 #define CPU_FLAGS_MAX 128 #define MAX_CPUID_LEVEL 32 #define MAX_EXT_CPUID_LEVEL 32 diff --git a/libcpuid/libcpuid_util.c b/libcpuid/libcpuid_util.c index bd41640..a262e23 100644 --- a/libcpuid/libcpuid_util.c +++ b/libcpuid/libcpuid_util.c @@ -142,7 +142,7 @@ int match_cpu_codename(const struct match_entry_t* matchtable, int count, bestindex = i; } } - strcpy(data->cpu_codename, matchtable[bestindex].name); + strncpy(data->cpu_codename, matchtable[bestindex].name, CODENAME_STR_MAX); return bestscore; } diff --git a/libcpuid/libcpuid_util.h b/libcpuid/libcpuid_util.h index 560820f..c09357a 100644 --- a/libcpuid/libcpuid_util.h +++ b/libcpuid/libcpuid_util.h @@ -43,7 +43,7 @@ struct match_entry_t { int ncores, l2cache, l3cache, brand_code; uint64_t model_bits; int model_code; - char name[36]; + char name[CODENAME_STR_MAX]; }; // returns the match score: