{
FILE *fp;
char buffer[DATA_BUFF_MAX], *p, *q;
+ int len;
fp = fopen(SERIAL_PATH_NAME, "r");
if (!fp) {
q = strchrnul(p, '\n');
*q = '\0';
- strcpy(info.serial, p);
+ len = strlen(p) > DATA_BUFF_MAX-1 ? DATA_BUFF_MAX-1 : strlen(p);
+ strncpy(info.serial, p, len);
+ info.serial[len] = '\0';
info.serial_len = strlen(p);
fclose(fp);
{
FILE *fp;
char line[LINE_LEN], *p, *q;
+ int len;
fp = fopen(CPUINFO_PATH, "r");
if (!fp) {
q = strchrnul(p, '\n');
*q = '\0';
- strcpy(info.serial, p);
+ len = strlen(p) > DATA_BUFF_MAX-1 ? DATA_BUFF_MAX-1 : strlen(p);
+ strncpy(info.serial, p, len);
+ info.serial[len] = '\0';
info.serial_len = strlen(p);
fclose(fp);