[tracker/tracker-0.10] UTF-16 strings' length with 3 \0 bytes at the end was calculated wrong



commit d0ff881e5f17dbfb96846d211e7a317141689e37
Author: Philip Van Hoof <philip codeminded be>
Date:   Fri Jul 22 12:43:19 2011 +0200

    UTF-16 strings' length with 3 \0 bytes at the end was calculated wrong
    
    Fixes NB#274181.

 src/tracker-extract/tracker-extract-mp3.c |   10 +++++++++-
 1 files changed, 9 insertions(+), 1 deletions(-)
---
diff --git a/src/tracker-extract/tracker-extract-mp3.c b/src/tracker-extract/tracker-extract-mp3.c
index 8c0f983..c416022 100644
--- a/src/tracker-extract/tracker-extract-mp3.c
+++ b/src/tracker-extract/tracker-extract-mp3.c
@@ -1016,8 +1016,16 @@ id3v2_strlen (const gchar  encoding,
 	switch (encoding) {
 	case 0x01:
 	case 0x02:
+		
 		/* UTF-16, string terminated by two NUL bytes */
-		pos = memmem (text, len, "\0\0", 2);
+		pos = memmem (text, len, "\0\0\0", 3);
+
+		if (pos == NULL) {
+			pos = memmem (text, len, "\0\0", 2);
+		} else {
+			pos++;
+		}
+
 		if (pos != NULL) {
 			return pos - text;
 		} else {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]