Use sideband also for challenge response.
[paraslash.git] / spx_afh.c
index e693c4150e03b7dae9b991c343ec7abbfe980db0..bc2c6c42b7c087234bf4d97a3883d0bd2e4221c3 100644 (file)
--- a/spx_afh.c
+++ b/spx_afh.c
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2010-2011 Andre Noll <maan@systemlinux.org>
+ * Copyright (C) 2010-2012 Andre Noll <maan@systemlinux.org>
  *
  * Licensed under the GPL v2. For licencing details see COPYING.
  */
@@ -38,7 +38,6 @@
 */
 /** \file spx_afh.c Audio format handler for ogg/speex files. */
 
-#include <stdbool.h>
 #include <ogg/ogg.h>
 #include <regex.h>
 #include <speex/speex.h>
@@ -57,31 +56,14 @@ struct private_spx_data {
        struct spx_header_info shi;
 };
 
-
-static char *copy_comment(const char *src, int len)
-{
-       char *p = para_malloc(len + 1);
-
-       if (len > 0)
-               memcpy(p, src, len);
-       p[len] = '\0';
-       PARA_DEBUG_LOG("%s\n", p);
-       return p;
-}
-
 static bool copy_if_tag_type(const char *tag, int taglen, const char *type,
                char **p)
 {
-       int len = strlen(type);
-
-       if (taglen <= len)
-               return false;
-       if (strncasecmp(tag, type, len))
-               return false;
-       if (tag[len] != '=')
+       char *q = key_value_copy(tag, taglen, type);
+       if (!q)
                return false;
        free(*p);
-       *p = copy_comment(tag + len + 1, taglen - len - 1);
+       *p = q;
        return true;
 }
 
@@ -100,7 +82,7 @@ static int spx_get_comments(unsigned char *comments, int length,
        c += 4;
        if (c + len > end)
                return -E_SPX_COMMENT;
-       tags->comment = copy_comment(c, len);
+       tags->comment = safe_strdup(c, len);
 
        c += len;
        if (c + 4 > end)
@@ -129,7 +111,7 @@ static int spx_get_comments(unsigned char *comments, int length,
                        continue;
                if (copy_if_tag_type(c, len, "comment", &tags->comment))
                        continue;
-               tag = copy_comment(c, len);
+               tag = safe_strdup(c, len);
                PARA_NOTICE_LOG("unrecognized comment: %s\n", tag);
                free(tag);
        }