make it take size after all

This commit is contained in:
2026-05-11 11:01:37 +00:00
parent c26ccba813
commit 574f59b8f5
5 changed files with 8 additions and 8 deletions

View File

@@ -55,12 +55,12 @@ inline bool file_exists(const char *path) {
}
/* path has to have at least 8 free chars at the end for glob */
int get_hwmon_dir(char *path) {
int get_hwmon_dir(char *path, const size_t bufsz) {
glob_t g;
strncat(path, "/hwmon*", 10);
if (glob(path, 0, NULL, &g) == 0) {
strncpy(path, g.gl_pathv[0], 128); // bug prone, careful
strncpy(path, g.gl_pathv[0], bufsz); // same size as hwmon length, careful
globfree(&g);
return 0;
}