Skip to content

Commit 52b8aef

Browse files
committed
Fix build system regression and enhance string safety in core
- Restored missing if-block in CMakeLists.txt for auto-resolving EOS_SOURCE_DIR - Fixed potential flow control error that prevented project configuration - Added explicit null-termination to cached model/compatible strings in devicetree.c - Replaced unsafe strcpy with strncpy in filesystem service initialization - Verified changes with successful build and full ctest suite Signed-off-by: RinZ27 <222222878+RinZ27@users.noreply.github.com>
1 parent 71d7555 commit 52b8aef

8 files changed

Lines changed: 52 additions & 229 deletions

File tree

CMakeLists.txt

Lines changed: 4 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,10 @@ endif()
3737
# ================================================================
3838
message(STATUS "=== EoS Platform v${PROJECT_VERSION} ===")
3939
message(STATUS " Target: ${EOS_TARGET}")
40-
set(EOS_SOURCE_DIR "" CACHE PATH "Path to EoS source (auto-resolved if empty)")
41-
# Allow user to override repo paths at cmake configure time
40+
4241
set(EOS_SOURCE_DIR "" CACHE PATH "Path to EoS source (auto-resolved if empty)")
4342
set(EBOOT_SOURCE_DIR "" CACHE PATH "Path to eBoot source (auto-resolved if empty)")
44-
if(EXISTS "$ENV{HOME}/.ebuild/repos/eos/CMakeLists.txt")
43+
4544
# --- Auto-resolve EoS source directory ---
4645
if(NOT EOS_SOURCE_DIR OR EOS_SOURCE_DIR STREQUAL "")
4746
# 1. Check ~/.ebuild/repos/eos (cached clone)
@@ -55,15 +54,15 @@ if(NOT EOS_SOURCE_DIR OR EOS_SOURCE_DIR STREQUAL "")
5554
# 3. Fallback to embedded core/eos
5655
elseif(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/core/eos/CMakeLists.txt")
5756
set(EOS_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/core/eos")
58-
message(WARNING "Using embedded core/eos/ is deprecated. Run 'ebuild setup' to use cached repos.")
57+
message(WARNING "Using embedded core/eos/ — run 'ebuild setup' to use cached repos instead.")
5958
endif()
6059
endif()
6160

6261
if(EOS_SOURCE_DIR AND EXISTS "${EOS_SOURCE_DIR}/CMakeLists.txt")
6362
add_subdirectory(${EOS_SOURCE_DIR} ${CMAKE_BINARY_DIR}/eos)
6463
message(STATUS " Core/EoS: ON (${EOS_SOURCE_DIR})")
6564
else()
66-
message(WARNING "EoS source not found. Run 'ebuild setup' or pass -DEOS_SOURCE_DIR=<path>.")
65+
message(WARNING "EoS source not found. Run 'ebuild setup' or set -DEOS_SOURCE_DIR=<path>.")
6766
endif()
6867

6968
# --- Auto-resolve eBoot source directory ---
@@ -77,50 +76,6 @@ if(NOT EBOOT_SOURCE_DIR OR EBOOT_SOURCE_DIR STREQUAL "")
7776
elseif(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/../eboot/CMakeLists.txt")
7877
get_filename_component(EBOOT_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../eboot" ABSOLUTE)
7978
# 3. Fallback to embedded core/eboot
80-
elseif(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/core/eboot/CMakeLists.txt")
81-
set(EBOOT_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/core/eboot")
82-
message(WARNING "Using embedded core/eboot/ is deprecated. Run 'ebuild setup' to use cached repos.")
83-
endif()
84-
endif()
85-
86-
if(EBOOT_SOURCE_DIR AND EXISTS "${EBOOT_SOURCE_DIR}/CMakeLists.txt")
87-
add_subdirectory(${EBOOT_SOURCE_DIR} ${CMAKE_BINARY_DIR}/eboot)
88-
message(STATUS " Core/eBoot: ON (${EBOOT_SOURCE_DIR})")
89-
else()
90-
message(WARNING "eBoot source not found. Run 'ebuild setup' or pass -DEBOOT_SOURCE_DIR=<path>.")
91-
endif()
92-
93-
set(EOS_SOURCE_DIR "$ENV{HOME}/.ebuild/repos/eos")
94-
elseif(EXISTS "$ENV{USERPROFILE}/.ebuild/repos/eos/CMakeLists.txt")
95-
set(EOS_SOURCE_DIR "$ENV{USERPROFILE}/.ebuild/repos/eos")
96-
# 2. Check sibling directory ../eos
97-
elseif(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/../eos/CMakeLists.txt")
98-
get_filename_component(EOS_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../eos" ABSOLUTE)
99-
# 3. Fallback to embedded core/eos
100-
elseif(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/core/eos/CMakeLists.txt")
101-
set(EOS_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/core/eos")
102-
message(WARNING "Using embedded core/eos/ — run 'ebuild setup' to use cached repos instead.")
103-
endif()
104-
endif()
105-
106-
if(EOS_SOURCE_DIR AND EXISTS "${EOS_SOURCE_DIR}/CMakeLists.txt")
107-
add_subdirectory(${EOS_SOURCE_DIR} ${CMAKE_BINARY_DIR}/eos)
108-
message(STATUS " Core/EoS: ON (${EOS_SOURCE_DIR})")
109-
else()
110-
message(WARNING "EoS source not found. Run 'ebuild setup' or set -DEOS_SOURCE_DIR=<path>.")
111-
endif()
112-
113-
# --- Auto-resolve eBoot source directory ---
114-
if(NOT EBOOT_SOURCE_DIR)
115-
# 1. Check ~/.ebuild/repos/eboot (cached clone)
116-
if(EXISTS "$ENV{HOME}/.ebuild/repos/eboot/CMakeLists.txt")
117-
set(EBOOT_SOURCE_DIR "$ENV{HOME}/.ebuild/repos/eboot")
118-
elseif(EXISTS "$ENV{USERPROFILE}/.ebuild/repos/eboot/CMakeLists.txt")
119-
set(EBOOT_SOURCE_DIR "$ENV{USERPROFILE}/.ebuild/repos/eboot")
120-
# 2. Check sibling directory ../eboot
121-
elseif(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/../eboot/CMakeLists.txt")
122-
get_filename_component(EBOOT_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../eboot" ABSOLUTE)
123-
# 3. Fallback to embedded core/eboot
12479
elseif(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/core/eboot/CMakeLists.txt")
12580
set(EBOOT_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/core/eboot")
12681
message(WARNING "Using embedded core/eboot/ — run 'ebuild setup' to use cached repos instead.")

core/eos/drivers/devicetree/devicetree.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,10 +81,13 @@ int eos_dt_parse(EosDeviceTree *dt, const uint8_t *dtb, uint32_t size) {
8181

8282
/* Cache model and compatible at root level */
8383
if (depth == 1) {
84-
if (strcmp(pname, "model") == 0)
84+
if (strcmp(pname, "model") == 0) {
8585
strncpy(dt->model, (const char *)prop->data, 63);
86-
else if (strcmp(pname, "compatible") == 0)
86+
dt->model[63] = '\0';
87+
} else if (strcmp(pname, "compatible") == 0) {
8788
strncpy(dt->compatible, (const char *)prop->data, 127);
89+
dt->compatible[127] = '\0';
90+
}
8891
}
8992
if (strcmp(pname, "phandle") == 0 && len >= 4)
9093
node->phandle = be32(prop->data);

core/eos/services/filesystem/src/filesystem.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ static uint32_t g_used = 0;
2323
int eos_fs_init(const eos_fs_config_t *cfg) {
2424
(void)cfg;
2525
memset(g_inodes, 0, sizeof(g_inodes)); memset(g_fds, 0, sizeof(g_fds)); memset(g_dirs, 0, sizeof(g_dirs));
26-
g_inodes[0].in_use = 1; g_inodes[0].is_dir = 1; strcpy(g_inodes[0].name, "/");
26+
g_inodes[0].in_use = 1; g_inodes[0].is_dir = 1; strncpy(g_inodes[0].name, "/", EOS_PATH_MAX - 1);
27+
g_inodes[0].name[EOS_PATH_MAX - 1] = '\0';
2728
g_used = 0; g_init = 1; return 0;
2829
}
2930

ebuild/cli/commands.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,10 @@
1414
import subprocess
1515
import sys
1616
from pathlib import Path
17-
from typing import Any, Dict, List, Optional, Tuple
17+
from typing import Any, Dict, List, Optional, Tuple, TYPE_CHECKING
18+
19+
if TYPE_CHECKING:
20+
from ebuild.eos_ai.eos_hw_analyzer import HardwareProfile
1821

1922
import click
2023
import yaml
@@ -23,14 +26,14 @@
2326
from ebuild.build.ninja_backend import NinjaBackend, PackagePaths
2427
from ebuild.build.toolchain import resolve_toolchain
2528
from ebuild.cli.logger import Logger
26-
from ebuild.core.config import ConfigError, PackageDep, load_config, ProjectConfig
29+
from ebuild.core.config import ConfigError, load_config, ProjectConfig
2730
from ebuild.core.graph import CycleError, build_dependency_graph
2831
from ebuild.packages.builder import BuildError, PackageBuilder
2932
from ebuild.packages.cache import PackageCache
3033
from ebuild.packages.fetcher import FetchError, PackageFetcher
3134
from ebuild.packages.lockfile import Lockfile
32-
from ebuild.packages.recipe import PackageRecipe, RecipeError
33-
from ebuild.packages.registry import PackageRegistry, create_registry
35+
from ebuild.packages.recipe import RecipeError
36+
from ebuild.packages.registry import create_registry
3437
from ebuild.packages.resolver import PackageResolver, ResolveError
3538

3639

@@ -1440,9 +1443,9 @@ def new(log: Logger, project_name: str, template_name: str, board_name: str,
14401443
log.success(f" {output_path.relative_to(parent)}")
14411444

14421445
log.success(f"\nProject created: {project_dir}")
1443-
log.info(f"\nNext steps:")
1446+
log.info("\nNext steps:")
14441447
log.info(f" cd {project_name}")
1445-
log.info(f" ebuild build")
1448+
log.info(" ebuild build")
14461449

14471450

14481451
@cli.command("generate-boot")

ebuild/deliverable_packager.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@
1414
1515
Output: eos-{target}-v{version}-deliverable.zip
1616
"""
17-
import os, json, shutil, zipfile, sys
17+
import os
18+
import json
19+
import shutil
20+
import zipfile
21+
import sys
1822
from datetime import datetime, timezone
1923

2024
try:

0 commit comments

Comments
 (0)