Address code review feedback: fix buffer overflows and remove remaining user configs

Co-authored-by: johndoe6345789 <224850594+johndoe6345789@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2026-01-02 01:48:17 +00:00
parent 5bc97ca74b
commit ebb5a3a37f
3 changed files with 9 additions and 4 deletions

View File

@@ -90,7 +90,6 @@ chmod 755 /staging/root/sbin/init
echo "sparkos" > /staging/root/etc/hostname echo "sparkos" > /staging/root/etc/hostname
echo "127.0.0.1 localhost" > /staging/root/etc/hosts echo "127.0.0.1 localhost" > /staging/root/etc/hosts
echo "127.0.1.1 sparkos" >> /staging/root/etc/hosts echo "127.0.1.1 sparkos" >> /staging/root/etc/hosts
echo "spark:x:1000:" >> /staging/root/etc/group
# Copy README to root partition # Copy README to root partition
cp /build/config/image-readme.txt /staging/root/README.txt cp /build/config/image-readme.txt /staging/root/README.txt

View File

@@ -65,7 +65,6 @@ chmod 755 /staging/root/sbin/init
echo "sparkos" > /staging/root/etc/hostname echo "sparkos" > /staging/root/etc/hostname
echo "127.0.0.1 localhost" > /staging/root/etc/hosts echo "127.0.0.1 localhost" > /staging/root/etc/hosts
echo "127.0.1.1 sparkos" >> /staging/root/etc/hosts echo "127.0.1.1 sparkos" >> /staging/root/etc/hosts
echo "spark:x:1000:" >> /staging/root/etc/group
# Copy README to root partition # Copy README to root partition
cp /build/config/image-readme.txt /staging/root/README.txt cp /build/config/image-readme.txt /staging/root/README.txt

View File

@@ -23,6 +23,7 @@
#include <errno.h> #include <errno.h>
#include <string.h> #include <string.h>
#include <arpa/inet.h> #include <arpa/inet.h>
#include <limits.h>
static void signal_handler(int sig) { static void signal_handler(int sig) {
if (sig == SIGCHLD) { if (sig == SIGCHLD) {
@@ -81,6 +82,7 @@ static int init_network_interface(const char *ifname) {
// Prepare interface request structure // Prepare interface request structure
memset(&ifr, 0, sizeof(ifr)); memset(&ifr, 0, sizeof(ifr));
strncpy(ifr.ifr_name, ifname, IFNAMSIZ - 1); strncpy(ifr.ifr_name, ifname, IFNAMSIZ - 1);
ifr.ifr_name[IFNAMSIZ - 1] = '\0'; // Ensure null termination
// Get current flags // Get current flags
if (ioctl(sock, SIOCGIFFLAGS, &ifr) < 0) { if (ioctl(sock, SIOCGIFFLAGS, &ifr) < 0) {
@@ -148,12 +150,17 @@ static int mount_fs(const char *source, const char *target, const char *fstype,
* No dependency on mkdir binary * No dependency on mkdir binary
*/ */
static int mkdir_p(const char *path) { static int mkdir_p(const char *path) {
char tmp[256]; char tmp[PATH_MAX];
char *p = NULL; char *p = NULL;
size_t len; size_t len;
len = strlen(path);
if (len >= PATH_MAX) {
errno = ENAMETOOLONG;
return -1;
}
snprintf(tmp, sizeof(tmp), "%s", path); snprintf(tmp, sizeof(tmp), "%s", path);
len = strlen(tmp);
if (tmp[len - 1] == '/') if (tmp[len - 1] == '/')
tmp[len - 1] = 0; tmp[len - 1] = 0;