summaryrefslogtreecommitdiffstats
path: root/lib/util.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-04 01:11:49 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-04 01:11:49 +0000
commit1b88cd5ee8510e90e69f885bfd730ce57621781c (patch)
treeb6b33bd695258f68c68824029c279d660ee4b85e /lib/util.c
parentAdding upstream version 3:4.8.30. (diff)
downloadmc-1b88cd5ee8510e90e69f885bfd730ce57621781c.tar.xz
mc-1b88cd5ee8510e90e69f885bfd730ce57621781c.zip
Adding upstream version 3:4.8.31.upstream/3%4.8.31upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'lib/util.c')
-rw-r--r--lib/util.c17
1 files changed, 14 insertions, 3 deletions
diff --git a/lib/util.c b/lib/util.c
index 744bd9e..b766f7c 100644
--- a/lib/util.c
+++ b/lib/util.c
@@ -1,7 +1,7 @@
/*
Various utilities
- Copyright (C) 1994-2023
+ Copyright (C) 1994-2024
Free Software Foundation, Inc.
Written by:
@@ -256,6 +256,9 @@ name_quote (const char *s, gboolean quote_percent)
{
GString *ret;
+ if (s == NULL || *s == '\0')
+ return NULL;
+
ret = g_string_sized_new (64);
if (*s == '-')
@@ -305,7 +308,7 @@ name_quote (const char *s, gboolean quote_percent)
g_string_append_c (ret, *s);
}
- return g_string_free (ret, FALSE);
+ return g_string_free (ret, ret->len == 0);
}
/* --------------------------------------------------------------------------------------------- */
@@ -314,7 +317,8 @@ char *
fake_name_quote (const char *s, gboolean quote_percent)
{
(void) quote_percent;
- return g_strdup (s);
+
+ return (s == NULL || *s == '\0' ? NULL : g_strdup (s));
}
/* --------------------------------------------------------------------------------------------- */
@@ -887,6 +891,11 @@ get_compression_type (int fd, const char *name)
&& magic[2] == 'Z' && magic[3] == 'M' && magic[4] == 'A' && magic[5] == 0x00)
return COMPRESSION_LZMA;
+ /* LZO format - \x89\x4c\x5a\x4f\x00\x0d\x0a\x1a\x0a lzop compressed data */
+ if (magic[0] == 0x89 && magic[1] == 0x4c &&
+ magic[2] == 0x5a && magic[3] == 0x4f && magic[4] == 0x00 && magic[5] == 0x0d)
+ return COMPRESSION_LZO;
+
/* XZ compression magic */
if (magic[0] == 0xFD
&& magic[1] == 0x37
@@ -926,6 +935,8 @@ decompress_extension (int type)
return "/ulz4" VFS_PATH_URL_DELIMITER;
case COMPRESSION_LZMA:
return "/ulzma" VFS_PATH_URL_DELIMITER;
+ case COMPRESSION_LZO:
+ return "/ulzo" VFS_PATH_URL_DELIMITER;
case COMPRESSION_XZ:
return "/uxz" VFS_PATH_URL_DELIMITER;
case COMPRESSION_ZSTD: