]> git.ipfire.org Git - thirdparty/asterisk.git/commitdiff
format_ogg_speex: Implement a "not supported" write handler
authorKevin Harwell <kharwell@sangoma.com>
Tue, 3 Aug 2021 16:30:54 +0000 (11:30 -0500)
committerGeorge Joseph <gjoseph@digium.com>
Fri, 6 Aug 2021 12:52:55 +0000 (07:52 -0500)
This format did not specify a "write" handler, so when attempting to write
to it (ast_writestream) a crash would occur.

This patch adds a default handler that simply issues a "not supported"
warning, thus no longer crashing.

ASTERISK-29539

Change-Id: I8f6ddc7cc3b15da30803be3b1cf68e2ba0fbce91

formats/format_ogg_speex.c

index ff26c9d22cff8da35f16e08092a24e7804479622..0d7a8fd596da03acc1bade370ed5970958aafcad 100644 (file)
@@ -254,6 +254,12 @@ static int ogg_speex_trunc(struct ast_filestream *s)
        return -1;
 }
 
+static int ogg_speex_write(struct ast_filestream *s, struct ast_frame *f)
+{
+       ast_log(LOG_WARNING, "Writing is not supported on OGG/Speex streams!\n");
+       return -1;
+}
+
 /*!
  * \brief Seek to a specific position in an OGG/Speex filestream.
  * \param s The filestream to truncate.
@@ -277,6 +283,7 @@ static struct ast_format_def speex_f = {
        .name = "ogg_speex",
        .exts = "spx",
        .open = ogg_speex_open,
+       .write = ogg_speex_write,
        .seek = ogg_speex_seek,
        .trunc = ogg_speex_trunc,
        .tell = ogg_speex_tell,
@@ -290,6 +297,7 @@ static struct ast_format_def speex16_f = {
        .name = "ogg_speex16",
        .exts = "spx16",
        .open = ogg_speex_open,
+       .write = ogg_speex_write,
        .seek = ogg_speex_seek,
        .trunc = ogg_speex_trunc,
        .tell = ogg_speex_tell,
@@ -303,6 +311,7 @@ static struct ast_format_def speex32_f = {
        .name = "ogg_speex32",
        .exts = "spx32",
        .open = ogg_speex_open,
+       .write = ogg_speex_write,
        .seek = ogg_speex_seek,
        .trunc = ogg_speex_trunc,
        .tell = ogg_speex_tell,