make it take size after all
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user