}
/*
- * Read the next element as an ASCII string.
+ * Read the next element as a C string.
*/
-GstFlowReturn
-gst_ebml_read_ascii (GstEbmlRead * ebml, guint32 * id, gchar ** str)
+static GstFlowReturn
+gst_ebml_read_string (GstEbmlRead * ebml, guint32 * id, gchar ** str)
{
guint8 *data;
guint size;
return ret;
}
+/*
+ * Read the next element as an ASCII string.
+ */
+
+GstFlowReturn
+gst_ebml_read_ascii (GstEbmlRead * ebml, guint32 * id, gchar ** str)
+{
+ GstFlowReturn ret;
+ gchar *iter;
+
+#ifndef GST_DISABLE_GST_DEBUG
+ guint64 oldoff = ebml->offset;
+#endif
+
+ ret = gst_ebml_read_string (ebml, id, str);
+ if (ret != GST_FLOW_OK)
+ return ret;
+
+ for (iter = *str; *iter != '\0'; iter++) {
+ if (G_UNLIKELY (*iter & 0x80)) {
+ GST_ERROR_OBJECT (ebml,
+ "Invalid ASCII string at offset %" G_GUINT64_FORMAT, oldoff);
+ g_free (*str);
+ return GST_FLOW_ERROR;
+ }
+ }
+
+ return ret;
+}
+
/*
* Read the next element as a UTF-8 string.
*/
guint64 oldoff = ebml->offset;
#endif
- ret = gst_ebml_read_ascii (ebml, id, str);
+ ret = gst_ebml_read_string (ebml, id, str);
if (ret != GST_FLOW_OK)
return ret;