free(copy);
return;
}
- strcat(pkg_list, addon);
+
+ strncat(pkg_list, addon, remain - 1); // terminating null byte
LOGINFO("remove packages: %s", pkg_list);
return false;
}
- strcat(pkg_list, pkg);
+ strncat(pkg_list, pkg, remain - 1); // terminating null byte
pkg = strtok(NULL, token);
}
int ret = 0;
if (fp == NULL) {
- LOGERR("fail to read /proc/cmdline");
+ LOGERR("failed to open /proc/cmdline");
return -1;
}
+
if (getline(&line, &len, fp) != -1) {
LOGINFO("line: %s", line);
LOGINFO("len: %d", len);
}
+ if (!line)
+ {
+ LOGERR("failed to read /proc/cmdline");
+ return -1;
+ }
+
if (get_str_cmdline(line, IP_SUFFIX, str, str_size) < 1) {
LOGINFO("could not get the (%s) value from cmdline. static ip does not set.", IP_SUFFIX);
ret = -1;
}
- if(line)
- free(line);
+ free(line);
fclose(fp);
LOGINFO("succeeded to get guest_net: %s", str);