]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
stasis_recording: Perform a complete match on requested filename.
authorSean Bright <sean.bright@gmail.com>
Thu, 10 Mar 2022 17:07:40 +0000 (12:07 -0500)
committerFriendly Automation <jenkins2@gerrit.asterisk.org>
Wed, 23 Mar 2022 20:08:16 +0000 (15:08 -0500)
Using the length of a file found on the filesystem rather than the
file being requested could result in filenames whose names are
substrings of another to be erroneously matched.

We now ensure a complete comparison before returning a positive
result.

ASTERISK-29960 #close

Change-Id: Id3ffc77681b9b75b8569062f3d952a128a21c71a

res/stasis_recording/stored.c

index 6cdca96e2bb8990342f86945293cb78c84517c6c..9e9ae58343302f7b30709f4e3418bcfc2f411cd7 100644 (file)
@@ -130,6 +130,7 @@ static int split_path(const char *path, char **dir, char **file)
 
 struct match_recording_data {
        const char *file;
+       size_t length;
        char *file_with_ext;
 };
 
@@ -160,7 +161,9 @@ static int handle_find_recording(const char *dir_name, const char *filename, voi
        int num;
 
        /* If not a recording or the names do not match the keep searching */
-       if (!(num = is_recording(filename)) || strncmp(data->file, filename, num)) {
+       if (!(num = is_recording(filename))
+          || data->length != num
+          || strncmp(data->file, filename, num)) {
                return 0;
        }
 
@@ -186,6 +189,7 @@ static char *find_recording(const char *dir_name, const char *file)
 {
        struct match_recording_data data = {
                .file = file,
+               .length = strlen(file),
                .file_with_ext = NULL
        };