From 8edc77fdb2320f24a3951e52521ce82061019652 Mon Sep 17 00:00:00 2001 From: Dan Rigdon-Bel Date: Tue, 8 Feb 2022 20:38:55 -0800 Subject: [PATCH] Use strcoll_l() for locale-independent comparisons (#2087) The update code uses the compareFiles function to determine the sort order of file names in a directory, which is then compared with a list of files in the Sparkle update info. If the list of files of a directory from Sparkle's update is different than what is on disk, the Sparkle abandons the update and does a full download. This bug would prevent Sparkle from updating properly when the file lists are calculated on an English language system, but then checked on a destination Japanese system. The fix is to use strcoll_l(), which is locale-independent, when comparing file names for sorting. This will ignore any locale changes the host application has made that could potentially affect Sparkle's sort order. --- Autoupdate/SUBinaryDeltaCommon.m | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Autoupdate/SUBinaryDeltaCommon.m b/Autoupdate/SUBinaryDeltaCommon.m index 13662464..533b18b1 100644 --- a/Autoupdate/SUBinaryDeltaCommon.m +++ b/Autoupdate/SUBinaryDeltaCommon.m @@ -16,6 +16,7 @@ #include #include #include +#include #include "AppKitPrevention.h" @@ -89,7 +90,7 @@ NSString *deltaCompressionStringFromMode(SPUDeltaCompressionMode mode) int compareFiles(const FTSENT **a, const FTSENT **b) { - return strcoll((*a)->fts_name, (*b)->fts_name); + return strcoll_l((*a)->fts_name, (*b)->fts_name, _c_locale); } NSString *pathRelativeToDirectory(NSString *directory, NSString *path)