From 3a85c62f63ed1f727432ccab1dd46bfd7fd78404 Mon Sep 17 00:00:00 2001 From: Tilman Sauerbeck Date: Fri, 11 Aug 2006 15:34:19 +0200 Subject: [PATCH] Made sure that all comments are well-formed before they are parsed. ie, check that every comment has a '=' sign somewhere, but not at position 0. --- ext/ext.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/ext/ext.c b/ext/ext.c index d8bcc12..4794d28 100644 --- a/ext/ext.c +++ b/ext/ext.c @@ -130,7 +130,7 @@ c_init (VALUE self, VALUE io) { RbVorbisTagger *o; vorbis_comment *vc; - int s; + int s, i; Data_Get_Struct (self, RbVorbisTagger, o); @@ -165,6 +165,15 @@ c_init (VALUE self, VALUE io) rb_raise (eVTError, "vcedit_comments() failed - %s", vcedit_error (o->state)); + /* check whether all comments are well-formed */ + for (i = 0; i < vc->comments; i++) { + char *ptr, *content = vc->user_comments[i]; + + ptr = strchr (content, '='); + if (!ptr || ptr == content) + rb_raise (eVTError, "malformed comment - %s", content); + } + o->comments = rb_class_new_instance (0, NULL, cComments); comments_init (o->comments, o->state); -- 2.30.2