aboutsummaryrefslogtreecommitdiffstats
path: root/misc/shared-mime-info
diff options
context:
space:
mode:
authormarcus <marcus@FreeBSD.org>2004-12-05 05:10:03 +0800
committermarcus <marcus@FreeBSD.org>2004-12-05 05:10:03 +0800
commit0d3eb9c34a1ea7abd6a490aa2f9cdc655adfcf44 (patch)
treed08d8feb445a4c46551d6afb48c109c29d417534 /misc/shared-mime-info
parent262a5af31c40d4f9a085b5400b0f6fa3c678dcbe (diff)
downloadfreebsd-ports-gnome-0d3eb9c34a1ea7abd6a490aa2f9cdc655adfcf44.tar.gz
freebsd-ports-gnome-0d3eb9c34a1ea7abd6a490aa2f9cdc655adfcf44.tar.zst
freebsd-ports-gnome-0d3eb9c34a1ea7abd6a490aa2f9cdc655adfcf44.zip
Fix a potential overflow leading to incorrect MIME detection on 64-bit
and bigendian platforms. See https://bugs.freedesktop.org/show_bug.cgi?id=1506 https://bugs.freedesktop.org/show_bug.cgi?id=1507 For more details. Reported by: Sean McNeil <sean@mcneil.com> Obtained from: FreeDesktop CVS
Diffstat (limited to 'misc/shared-mime-info')
-rw-r--r--misc/shared-mime-info/Makefile9
-rw-r--r--misc/shared-mime-info/files/patch-Makefile.in16
-rw-r--r--misc/shared-mime-info/files/patch-update-mime-database.c82
3 files changed, 105 insertions, 2 deletions
diff --git a/misc/shared-mime-info/Makefile b/misc/shared-mime-info/Makefile
index a9e8eee95834..525078119e20 100644
--- a/misc/shared-mime-info/Makefile
+++ b/misc/shared-mime-info/Makefile
@@ -6,6 +6,7 @@
PORTNAME= shared-mime-info
PORTVERSION= 0.15
+PORTREVISION= 1
CATEGORIES= misc gnome
MASTER_SITES= http://www.marcuscom.com/downloads/ \
http://www.freedesktop.org/software/shared-mime-info/
@@ -20,7 +21,15 @@ USE_GNOME= glib20 libxml2 intltool gnomehack
MAN1= update-mime-database.1
+MIMEDIRS= ${X11BASE}/share/gnome/mime \
+ ${LOCALBASE}/share/gnome/mime \
+ ${X11BASE}/share/mime \
+ ${LOCALBASE}/share/mime \
+ /usr/share/mime
+
post-patch:
+ @${REINPLACE_CMD} -e 's|%%MIMEDIRS%%|${MIMEDIRS}|g' \
+ ${WRKSRC}/Makefile.in
@${REINPLACE_CMD} -e 's|/usr/local|${LOCALBASE}|g ; \
s|%%X11BASE%%|${X11BASE}|g' \
${WRKSRC}/update-mime-database.c
diff --git a/misc/shared-mime-info/files/patch-Makefile.in b/misc/shared-mime-info/files/patch-Makefile.in
new file mode 100644
index 000000000000..990f53a0adbb
--- /dev/null
+++ b/misc/shared-mime-info/files/patch-Makefile.in
@@ -0,0 +1,16 @@
+--- Makefile.in.orig Sat Dec 4 16:05:36 2004
++++ Makefile.in Sat Dec 4 16:06:17 2004
+@@ -795,7 +795,12 @@
+ @INTLTOOL_DESKTOP_RULE@
+
+ install-data-hook:
+-@ENABLE_UPDATE_MIMEDB_TRUE@ $(DESTDIR)"$(bindir)/update-mime-database" "$(DESTDIR)${mimedir}"
++@ENABLE_UPDATE_MIMEDB_TRUE@ for mdir in %%MIMEDIRS%%; do \
++@ENABLE_UPDATE_MIMEDB_TRUE@ if [ -d $${mdir} ]; then \
++@ENABLE_UPDATE_MIMEDB_TRUE@ $(DESTDIR)"$(bindir)/update-mime-database" "$${mdir}" ; \
++@ENABLE_UPDATE_MIMEDB_TRUE@ fi; \
++@ENABLE_UPDATE_MIMEDB_TRUE@ done
++
+
+ uninstall-hook:
+ for media in text application image audio inode video message model multipart; do rm -f "$(DESTDIR)${mimedir}/$${media}/"*.xml; done
diff --git a/misc/shared-mime-info/files/patch-update-mime-database.c b/misc/shared-mime-info/files/patch-update-mime-database.c
index d312ea0295b5..a9dbd47224bd 100644
--- a/misc/shared-mime-info/files/patch-update-mime-database.c
+++ b/misc/shared-mime-info/files/patch-update-mime-database.c
@@ -1,5 +1,5 @@
--- update-mime-database.c.orig Mon Oct 13 05:43:38 2003
-+++ update-mime-database.c Wed Jun 23 20:13:10 2004
++++ update-mime-database.c Sat Dec 4 15:52:53 2004
@@ -377,7 +377,8 @@
}
}
@@ -10,7 +10,85 @@
}
/* 'node' is a <mime-type> node from a source file, whose type is 'type'.
-@@ -1330,7 +1331,7 @@
+@@ -809,7 +810,13 @@
+ unsigned long value;
+ int b;
+
+- value = strtol(in, &end, 0);
++ value = strtoul(in, &end, 0);
++ if (errno == ERANGE) {
++ g_set_error(error, MIME_ERROR, 0,
++ "Number out-of-range (%s should fit in %d bytes)",
++ in, bytes);
++ return;
++ }
+ if (*end != '\0')
+ {
+ g_set_error(error, MIME_ERROR, 0, "Value is not a number");
+@@ -834,9 +841,16 @@
+ if (in_mask)
+ {
+ int b;
+- long mask;
+-
+- mask = strtol(in_mask, &end, 0);
++ unsigned long mask;
++
++ mask = strtoul(in_mask, &end, 0);
++ if (errno == ERANGE) {
++ g_set_error(error, MIME_ERROR, 0,
++ "Mask out-of-range (%s should fit in %d bytes)",
++ in_mask, bytes);
++ return;
++ }
++
+ if (*end != '\0')
+ {
+ g_set_error(error, MIME_ERROR, 0,
+@@ -847,7 +861,7 @@
+ out_mask = g_new(char, bytes);
+ for (b = 0; b < bytes; b++)
+ {
+- int shift = (bytes - b - 1) * 8;
++ int shift = (big_endian ? (bytes - b - 1) : b) * 8;
+ out_mask[b] = (mask >> shift) & 0xff;
+ }
+ }
+@@ -991,11 +1005,32 @@
+ }
+
+ match->range_start = strtol(offset, &end, 10);
++ if (errno == ERANGE) {
++ char *number;
++ number = g_strndup(offset, end-offset);
++ g_set_error(error, MIME_ERROR, 0,
++ "Number out-of-range (%s should fit in 4 bytes)",
++ number);
++ g_free(number);
++ return;
++ }
+ if (*end == ':' && end[1] && match->range_start >= 0)
+ {
+ int last;
++ char *begin;
++
++ begin = end + 1;
++ last = strtol(begin, &end, 10);
++ if (errno == ERANGE) {
++ char *number;
++ number = g_strndup(begin, end-begin);
++ g_set_error(error, MIME_ERROR, 0,
++ "Number out-of-range (%s should fit in 8 bytes)",
++ number);
++ g_free(number);
++ return;
++ }
+
+- last = strtol(end + 1, &end, 10);
+ if (*end == '\0' && last >= match->range_start)
+ match->range_length = last - match->range_start + 1;
+ else
+@@ -1330,7 +1365,7 @@
env = getenv("XDG_DATA_DIRS");
if (!env)