aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libselinux/src/label_file.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/libselinux/src/label_file.c b/libselinux/src/label_file.c
index 32525238..b6589681 100644
--- a/libselinux/src/label_file.c
+++ b/libselinux/src/label_file.c
@@ -111,9 +111,16 @@ static int load_mmap(struct selabel_handle *rec, const char *path,
uint32_t i, magic, version;
uint32_t entry_len, stem_map_len, regex_array_len;
- rc = snprintf(mmap_path, sizeof(mmap_path), "%s.bin", path);
- if (rc >= (int)sizeof(mmap_path))
- return -1;
+ len = strlen(path);
+ if (len > 4 && !strcmp(&path[len-4], ".bin")) {
+ if (len >= sizeof(mmap_path))
+ return -1;
+ strcpy(mmap_path, path);
+ } else {
+ rc = snprintf(mmap_path, sizeof(mmap_path), "%s.bin", path);
+ if (rc >= (int)sizeof(mmap_path))
+ return -1;
+ }
mmapfd = open(mmap_path, O_RDONLY | O_CLOEXEC);
if (mmapfd < 0)