libfuse: small safety and portability fixes across opt/cpu/fusermount/maintenance_thread

- fuse_opt: reformat process_opt_param to project style; return the
  rv from sscanf through a named local so the error branch prints
  the failing option cleanly.

- cpu.cpp: when parsing /sys/devices/system/cpu/*/topology/core_id,
  bail out cleanly on stream read failure rather than recording an
  uninitialized core_id.

- fusermount: free(copy) on the success path of parsing the mount
  option (previously leaked on every mount), and replace the fixed-
  buffer sprintf into procfile with snprintf bounded by the buffer
  size.

- maintenance_thread: widen the iteration count from int to u64
  so a long-lived daemon doesn't wrap after ~68 years of ticks
  (real effect: silence signed-overflow warnings under UBSan).
This commit is contained in:
Antonio S. Musumeci 2026-04-18 01:00:51 -04:00
parent a5043d801a
commit 861d52ceb3
4 changed files with 37 additions and 12 deletions

View file

@ -445,6 +445,7 @@ static int unmount_fuse_locked(const char *mnt, int quiet, int lazy)
}
out:
free(copy);
if (res == -1)
return -1;
@ -688,7 +689,7 @@ static int get_mnt_opts(int flags, char *opts, char **mnt_optsp)
if (add_option(mnt_optsp, "user=", strlen(user)) == -1)
return -1;
strcat(*mnt_optsp, user);
strcat(*mnt_optsp,user);
}
return 0;
}
@ -992,7 +993,7 @@ static int check_perm(const char **mntp, struct stat *stbuf, int *mountpoint_fd)
return -1;
}
sprintf(procfile, "/proc/self/fd/%i", *mountpoint_fd);
snprintf(procfile,sizeof(procfile),"/proc/self/fd/%i",*mountpoint_fd);
*mntp = procfile;
} else {
fprintf(stderr,