~ubuntu-branches/ubuntu/intrepid/amarok/intrepid-updates

« back to all changes in this revision

Viewing changes to debian/patches/security_audible_tags.diff

  • Committer: Bazaar Package Importer
  • Author(s): Harald Sitter
  • Date: 2009-01-19 22:05:24 UTC
  • Revision ID: james.westby@ubuntu.com-20090119220524-oiq6qur2isr1a7he
Tags: 2:1.4.10-0ubuntu3.1
* SECURITY UPDATE: integer overflows allow remote attackers to execute
  arbitrary code via an Audible Audio (.aa) file (LP: #318555)
  - debian/patches/security_audible_tags.diff fix integer overflow while
    reading audible aa file tags. Based on upstream patch.
  - http://websvn.kde.org/?view=rev&revision=908415
  - http://www.trapkit.de/advisories/TKADV2009-002.txt
  - CVE-2009-0135
  - CVE-2009-0136

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#
 
2
# Description: Fix Code execution via multiple integer overflows and array
 
3
#              index errors in the metadata parser for audible files.
 
4
# Patch: http://websvn.kde.org/?view=rev&revision=908415
 
5
#
 
6
#
 
7
Index: amarok-1.4.10/amarok/src/metadata/audible/audibletag.cpp
 
8
===================================================================
 
9
--- amarok-1.4.10.orig/amarok/src/metadata/audible/audibletag.cpp       2008-08-13 23:21:51.000000000 +0200
 
10
+++ amarok-1.4.10/amarok/src/metadata/audible/audibletag.cpp    2009-01-18 23:16:28.000000000 +0100
 
11
@@ -71,7 +71,8 @@
 
12
 {
 
13
     char buf[1023];
 
14
     fseek(fp, OFF_PRODUCT_ID, SEEK_SET);
 
15
-    fread(buf, strlen("product_id"), 1, fp);
 
16
+    if (fread(buf, strlen("product_id"), 1, fp) != 1)
 
17
+        return;
 
18
     if(memcmp(buf, "product_id", strlen("product_id")))
 
19
     {
 
20
         buf[20]='\0';
 
21
@@ -130,24 +131,65 @@
 
22
 
 
23
 bool Audible::Tag::readTag( FILE *fp, char **name, char **value)
 
24
 {
 
25
+    // arbitrary value that has to be smaller than 2^32-1 and that should be large enough for all tags
 
26
+    const uint32_t maxtaglen = 100000;
 
27
+
 
28
     uint32_t nlen;
 
29
-    fread(&nlen, sizeof(nlen), 1, fp);
 
30
+    if (fread(&nlen, sizeof(nlen), 1, fp) != 1)
 
31
+        return false;
 
32
     nlen = ntohl(nlen);
 
33
     //fprintf(stderr, "tagname len=%x\n", (unsigned)nlen);
 
34
-    *name = new char[nlen+1];
 
35
-    (*name)[nlen] = '\0';
 
36
+    if (nlen > maxtaglen)
 
37
+        return false;
 
38
 
 
39
     uint32_t vlen;
 
40
-    fread(&vlen, sizeof(vlen), 1, fp);
 
41
+    if (fread(&vlen, sizeof(vlen), 1, fp) != 1)
 
42
+        return false;
 
43
     vlen = ntohl(vlen);
 
44
     //fprintf(stderr, "tag len=%x\n", (unsigned)vlen);
 
45
+    if (vlen > maxtaglen)
 
46
+        return false;
 
47
+
 
48
+    *name = new char[nlen+1];
 
49
+    if (!*name)
 
50
+        return false;
 
51
+
 
52
     *value = new char[vlen+1];
 
53
+    if (!*value)
 
54
+    {
 
55
+        delete[] *name;
 
56
+        *name = 0;
 
57
+        return false;
 
58
+    }
 
59
+
 
60
+    (*name)[nlen] = '\0';
 
61
     (*value)[vlen] = '\0';
 
62
 
 
63
-    fread(*name, nlen, 1, fp);
 
64
-    fread(*value, vlen, 1, fp);
 
65
+    if (fread(*name, nlen, 1, fp) != 1)
 
66
+    {
 
67
+        delete[] *name;
 
68
+        *name = 0;
 
69
+        delete[] *value;
 
70
+        *value = 0;
 
71
+        return false;
 
72
+    }
 
73
+    if (fread(*value, vlen, 1, fp) != 1)
 
74
+    {
 
75
+        delete[] *name;
 
76
+        *name = 0;
 
77
+        delete[] *value;
 
78
+        *value = 0;
 
79
+        return false;
 
80
+    }
 
81
     char lasttag;
 
82
-    fread(&lasttag, 1, 1, fp);
 
83
+    if (fread(&lasttag, 1, 1, fp) != 1)
 
84
+    {
 
85
+        delete[] *name;
 
86
+        *name = 0;
 
87
+        delete[] *value;
 
88
+        *value = 0;
 
89
+        return false;
 
90
+    }
 
91
     //fprintf(stderr, "%s: \"%s\"\n", *name, *value);
 
92
 
 
93
     m_tagsEndOffset += 2 * 4 + nlen + vlen + 1;