Skip to content

Commit

Permalink
Roll xdg-mime to 722325fba8968a26eb243642cbe89a044d6dfd6c.
Browse files Browse the repository at this point in the history
$ git log 2cdd8d36d..722325fba --date=short --no-merges --format='%ad %ae %s'
2021-03-18 kdudka@redhat.com Fix fd leak in error path
2021-01-06 hadess@hadess.net ci: Add CI
2020-11-21 emmanuel.fleury@u-bordeaux.fr Fix signedness warnings in src/xdgmimecache.c
2020-11-21 emmanuel.fleury@u-bordeaux.fr Fix signedness warnings in src/xdgmimecache.c:__gio_xdg_cache_list_mime_parents()
2020-11-21 emmanuel.fleury@u-bordeaux.fr Fix signedness warning in src/xdgmimecache.c:__gio_xdg_cache_mime_type_subclass()
2020-11-21 emmanuel.fleury@u-bordeaux.fr Fix signedness warning in src/xdgmimecache.c:cache_glob_node_lookup_suffix()
2020-11-21 emmanuel.fleury@u-bordeaux.fr Fix signedness warning in rc/xdgmimecache.c:cache_glob_lookup_fnmatch()
2020-11-21 emmanuel.fleury@u-bordeaux.fr Fix signedness warning in src/xdgmimecache.c:cache_magic_compare_to_data()
2020-11-21 emmanuel.fleury@u-bordeaux.fr Fix signedness warning in src/xdgmimecache.c:cache_magic_matchlet_compare()
2020-11-21 emmanuel.fleury@u-bordeaux.fr Fix signedness warnings in src/xdgmimecache.c:cache_magic_matchlet_compare_to_data()
2020-11-21 emmanuel.fleury@u-bordeaux.fr Fix signedness warnings in src/xdgmimemagic.c:_xdg_mime_magic_matchlet_compare_to_data()
2020-11-21 emmanuel.fleury@u-bordeaux.fr Fix signedness warnings in src/xdgmimemagic.c:_xdg_mime_magic_parse_magic_line()
2020-11-21 emmanuel.fleury@u-bordeaux.fr Fix signedness warning in src/xdgmimeint.c
2020-12-27 faure@kde.org Fix fallback after multiple matching globs
2020-12-27 faure@kde.org Fix usage information for print-mime-data
2019-06-03 withnall@endlessm.com xdgmime: Don’t set an out argument if it’s NULL
2018-11-19 ville.skytta@iki.fi Comment grammar fix
2018-07-16 mcatanzaro@igalia.com Fix buffer underflow in __gio_xdg_cache_mime_type_subclass()
2018-07-16 mcatanzaro@igalia.com Fix special case for mime_type_subclass
2018-07-16 mcatanzaro@igalia.com Handle EINTR in open()
2018-07-16 mcatanzaro@igalia.com Don't forget to free resources on an early return
2018-07-16 mcatanzaro@igalia.com Fix void pointer arithmetic in cache_magic_matchlet_compare_to_data()
2018-07-16 mcatanzaro@igalia.com Fix use after free in xdg_mime_get_mime_type_for_file
2018-07-16 mcatanzaro@igalia.com Add space before paren in _xdg_mime_cache_get_mime_type_for_file
2018-06-30 mcatanzaro@igalia.com build: Add a .gitignore
2018-06-17 ville.skytta@iki.fi Spelling fixes
2017-09-05 hadess@hadess.net Check further into the file whether it is text or binary
2013-01-07 hadess@hadess.net tests: Fix current test-mime failures
2013-01-07 hadess@hadess.net tests: Make test-mime failures fatal
2013-01-07 hadess@hadess.net tests: Mime-types are not case-sensitive
2012-09-27 hadess@hadess.net Ignore non-regular files in print-mime-data
2012-09-25 hadess@hadess.net Add print-mime-data program

(cherry picked from commit a80974f)

Fixed: 1184294
Change-Id: I74717bb13d49088b18bd88404c7cf7b8032a7d99
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2803936
Reviewed-by: Adrian Taylor <adetaylor@chromium.org>
Reviewed-by: Thomas Anderson <thomasanderson@chromium.org>
Commit-Queue: Daniel Cheng <dcheng@chromium.org>
Cr-Original-Commit-Position: refs/heads/master@{#871055}
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2820648
Cr-Commit-Position: refs/branch-heads/4472@{#17}
Cr-Branched-From: 3d60439-refs/heads/master@{#870763}
  • Loading branch information
zetafunction authored and Chromium LUCI CQ committed Apr 12, 2021
1 parent bb7621d commit 2a4ba6d
Show file tree
Hide file tree
Showing 12 changed files with 207 additions and 119 deletions.
2 changes: 1 addition & 1 deletion base/third_party/xdg_mime/README
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
This module is a simple module that parses the proposed MIME spec listed
at http://freedesktop.org/. It is currently targetted at version 0.12.
at http://freedesktop.org/. It is currently targeted at version 0.12.
There are no formal releases planned for this module, and it is not
intended to be installed at this time. Rather, it is meant to be used
by other libraries or applications to add support for the MIME system.
Expand Down
20 changes: 10 additions & 10 deletions base/third_party/xdg_mime/README.chromium
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
Name: xdg-mime
URL: http://freedesktop.org
URL: https://gitlab.freedesktop.org/xdg/xdgmime
Version: 722325fba8968a26eb243642cbe89a044d6dfd6c
CPEPrefix: unknown
License: Academic Free License version 2.0 or LGPL v2
Security critical: yes

The code in this directory is synced from:
git://anongit.freedesktop.org/xdg/xdgmime
@ 2cdd8d36d7930d5a594587286cb1949ff62f7027 on 2012/08/06.
Run //base/third_party/xdg_mime/roll.py to update this dependency.

In addition, we have the following patch(es):
- compile.patch: small tweaks to make the code compile.
- free_pointer_later.patch: small patch that fixes potential crash in
xdg_mime_get_mime_type_for_file() - use of pointer after being freed.
- function_casts.patch: fix bad function casts.
- Added a LICENSE file.
Patches:
- 000-have-mmap.patch: enable code guarded with HAVE_MMAP since
Chrome does not run autoconf.
- 001-fix-casts-for-cfi.patch: remove casting between function
pointer types (!!!)
17 changes: 0 additions & 17 deletions base/third_party/xdg_mime/compile.patch

This file was deleted.

22 changes: 0 additions & 22 deletions base/third_party/xdg_mime/free_pointer_later.patch

This file was deleted.

13 changes: 13 additions & 0 deletions base/third_party/xdg_mime/patches/000-have-mmap.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
diff --git a/base/third_party/xdg_mime/xdgmimecache.c b/base/third_party/xdg_mime/xdgmimecache.c
index acaed9d470ed..ccf297527788 100644
--- a/base/third_party/xdg_mime/xdgmimecache.c
+++ b/base/third_party/xdg_mime/xdgmimecache.c
@@ -40,6 +40,8 @@

#include <netinet/in.h> /* for ntohl/ntohs */

+#define HAVE_MMAP 1
+
#ifdef HAVE_MMAP
#include <sys/mman.h>
#else
Original file line number Diff line number Diff line change
@@ -1,26 +1,28 @@
diff --git a/base/third_party/xdg_mime/xdgmime.c b/base/third_party/xdg_mime/xdgmime.c
index 6dc58c253fa2..f340fcefabb4 100644
index d178e06b05be..1a6a66959f96 100644
--- a/base/third_party/xdg_mime/xdgmime.c
+++ b/base/third_party/xdg_mime/xdgmime.c
@@ -136,7 +136,7 @@ xdg_dir_time_list_free (XdgDirTimeList *list)
}

static int
-xdg_mime_init_from_directory (const char *directory)
+xdg_mime_init_from_directory (const char *directory, void *user_data)
+xdg_mime_init_from_directory (const char *directory, void* unused)
{
char *file_name;
struct stat st;
@@ -340,8 +340,9 @@ xdg_check_file (const char *file_path,
@@ -340,10 +340,11 @@ xdg_check_file (const char *file_path,

static int
xdg_check_dir (const char *directory,
- int *invalid_dir_list)
+ void *user_data)
{
+ int *invalid_dir_list = user_data;
int invalid, exists;
char *file_name;
+ int* invalid_dir_list = user_data;

assert (directory != NULL);

@@ -398,8 +399,7 @@ xdg_check_dirs (void)
for (list = dir_time_list; list; list = list->next)
Expand Down
94 changes: 94 additions & 0 deletions base/third_party/xdg_mime/roll.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
#!/usr/bin/env python3

# Copyright 2021 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import os
import shlex
import shutil
import subprocess
import tempfile

_REPO_URL = "https://gitlab.freedesktop.org/xdg/xdgmime.git"
_FILES_TO_COPY = (
"README",
"src/xdgmimealias.c",
"src/xdgmime.c",
"src/xdgmimecache.h",
"src/xdgmimeglob.h",
"src/xdgmimeicon.c",
"src/xdgmimeint.c",
"src/xdgmimemagic.c",
"src/xdgmimeparent.c",
"src/xdgmimealias.h",
"src/xdgmimecache.c",
"src/xdgmimeglob.c",
"src/xdgmime.h",
"src/xdgmimeicon.h",
"src/xdgmimeint.h",
"src/xdgmimemagic.h",
"src/xdgmimeparent.h",
)

_PATCHES = ("000-have-mmap.patch", "001-fix-casts-for-cfi.patch")


def main():
out_dir = os.path.dirname(os.path.realpath(__file__))

with open(os.path.join(out_dir, "README.chromium")) as readme_file:
_VERSION_PREFIX = "Version: "
for line in readme_file:
if not line.startswith(_VERSION_PREFIX):
continue
old_commit = line[len(_VERSION_PREFIX):].strip()
with tempfile.TemporaryDirectory() as staging_dir:
os.chdir(staging_dir)

print(f"Cloning from {_REPO_URL}...")
subprocess.check_call([
"git",
"clone",
_REPO_URL,
".",
])

for f in _FILES_TO_COPY:
shutil.copy(os.path.join(staging_dir, f), out_dir)

new_commit = subprocess.check_output([
"git",
"rev-parse",
"HEAD",
]).decode("ascii").strip()

# This is cargo-culted from depot_tool's roll_dep.py
log_command = (
"git",
"log",
f"{old_commit}..{new_commit}",
"--date=short",
"--no-merges",
"--format=%ad %ae %s",
)
diffs = subprocess.check_output(log_command).decode("utf-8")

os.chdir(os.path.join(out_dir, "..", "..", ".."))

for p in _PATCHES:
print(f"Applying patch {p}...")
with open(os.path.join(out_dir, "patches", p)) as patch_file:
subprocess.check_call(["patch", "-p1"], stdin=patch_file)

print(f"Done! Updated from {old_commit} to {new_commit}")
print("Changes:")
print(
f"$ git log {old_commit[:9]}..{new_commit[:9]} "
f"--date=short --no-merges --format='%ad %ae %s'"
)
print(diffs)


if __name__ == "__main__":
main()
35 changes: 23 additions & 12 deletions base/third_party/xdg_mime/xdgmime.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ xdg_dir_time_list_free (XdgDirTimeList *list)
}

static int
xdg_mime_init_from_directory (const char *directory, void *user_data)
xdg_mime_init_from_directory (const char *directory, void* unused)
{
char *file_name;
struct stat st;
Expand Down Expand Up @@ -342,9 +342,9 @@ static int
xdg_check_dir (const char *directory,
void *user_data)
{
int *invalid_dir_list = user_data;
int invalid, exists;
char *file_name;
int* invalid_dir_list = user_data;

assert (directory != NULL);

Expand Down Expand Up @@ -470,7 +470,8 @@ xdg_mime_get_mime_type_for_data (const void *data,

if (len == 0)
{
*result_prio = 100;
if (result_prio != NULL)
*result_prio = 100;
return XDG_MIME_TYPE_EMPTY;
}

Expand Down Expand Up @@ -557,12 +558,12 @@ xdg_mime_get_mime_type_for_file (const char *file_name,
mime_type = _xdg_mime_magic_lookup_data (global_magic, data, bytes_read, NULL,
mime_types, n);

fclose (file);

if (!mime_type)
mime_type = _xdg_binary_or_text_fallback(data, bytes_read);
mime_type = _xdg_binary_or_text_fallback (data, bytes_read);

free (data);
fclose (file);

return mime_type;
}

Expand Down Expand Up @@ -740,19 +741,28 @@ xdg_mime_media_type_equal (const char *mime_a,

#if 1
static int
xdg_mime_is_super_type (const char *mime)
ends_with (const char *str,
const char *suffix)
{
int length;
const char *type;
int suffix_length;

length = strlen (mime);
type = &(mime[length - 2]);
length = strlen (str);
suffix_length = strlen (suffix);
if (length < suffix_length)
return 0;

if (strcmp (type, "/*") == 0)
if (strcmp (str + length - suffix_length, suffix) == 0)
return 1;

return 0;
}

static int
xdg_mime_is_super_type (const char *mime)
{
return ends_with (mime, "/*");
}
#endif

int
Expand Down Expand Up @@ -783,7 +793,8 @@ _xdg_mime_mime_type_subclass (const char *mime,
strncmp (umime, "text/", 5) == 0)
return 1;

if (strcmp (ubase, "application/octet-stream") == 0)
if (strcmp (ubase, "application/octet-stream") == 0 &&
strncmp (umime, "inode/", 6) != 0)
return 1;

parents = _xdg_mime_parent_list_lookup (parent_list, umime);
Expand Down

0 comments on commit 2a4ba6d

Please sign in to comment.