mirror of
https://github.com/AuxXxilium/eudev.git
synced 2024-11-23 23:10:57 +07:00
Merge pull request #198 from xfan1024/master
src/libudev/conf-files.c: fix bug of using basename
This commit is contained in:
commit
3b1286f970
@ -71,7 +71,7 @@ static int files_add(Hashmap *h, const char *root, const char *path, const char
|
||||
if (!p)
|
||||
return -ENOMEM;
|
||||
|
||||
r = hashmap_put(h, basename(p), p);
|
||||
r = hashmap_put(h, eudev_basename(p), p);
|
||||
if (r == -EEXIST) {
|
||||
log_debug("Skipping overridden file: %s.", p);
|
||||
free(p);
|
||||
@ -92,7 +92,7 @@ static int base_cmp(const void *a, const void *b) {
|
||||
|
||||
s1 = *(char * const *)a;
|
||||
s2 = *(char * const *)b;
|
||||
return strcmp(basename(s1), basename(s2));
|
||||
return strcmp(eudev_basename(s1), eudev_basename(s2));
|
||||
}
|
||||
|
||||
static int conf_files_list_strv_internal(char ***strv, const char *suffix, const char *root, char **dirs) {
|
||||
|
@ -1725,7 +1725,7 @@ int tempfn_xxxxxx(const char *p, char **ret) {
|
||||
* /foo/bar/.#waldoXXXXXX
|
||||
*/
|
||||
|
||||
fn = basename((char*)p);
|
||||
fn = eudev_basename(p);
|
||||
if (!filename_is_valid(fn))
|
||||
return -EINVAL;
|
||||
|
||||
@ -1967,3 +1967,11 @@ void cmsg_close_all(struct msghdr *mh) {
|
||||
if (cmsg->cmsg_level == SOL_SOCKET && cmsg->cmsg_type == SCM_RIGHTS)
|
||||
close_many((int*) CMSG_DATA(cmsg), (cmsg->cmsg_len - CMSG_LEN(0)) / sizeof(int));
|
||||
}
|
||||
|
||||
const char *eudev_basename(const char *filename) {
|
||||
const char *p = strrchr(filename, '/');
|
||||
|
||||
if (p)
|
||||
return p + 1;
|
||||
return filename;
|
||||
}
|
||||
|
@ -433,3 +433,4 @@ union inotify_event_buffer {
|
||||
};
|
||||
|
||||
void cmsg_close_all(struct msghdr *mh);
|
||||
const char *eudev_basename(const char *filename);
|
||||
|
Loading…
Reference in New Issue
Block a user