const up zxcvbn-c

Change-Id: Idbcff3cba17233a9d9746650cdda5129c0f4790b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/187788
Reviewed-by: Caolán McNamara <caolan.mcnamara@collabora.com>
Tested-by: Jenkins
This commit is contained in:
Caolán McNamara
2025-07-12 21:26:59 +01:00
parent e1b2c00b0a
commit 645ede66b2
2 changed files with 45 additions and 0 deletions

View File

@ -0,0 +1,42 @@
From fb847af696b873750adf2e61410d897d128f3dee Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Caol=C3=A1n=20McNamara?= <caolan.mcnamara@collabora.com>
Date: Sat, 12 Jul 2025 21:21:48 +0100
Subject: [PATCH] use const for these arrays
so they don't appear in the .data section. With const WordEndBits
ends up in the .rodata section and Formats in the .data.rel.ro
section.
---
dict-generate.cpp | 2 +-
zxcvbn.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/dict-generate.cpp b/dict-generate.cpp
index 878b4aa..7041be7 100644
--- a/dict-generate.cpp
+++ b/dict-generate.cpp
@@ -1246,7 +1246,7 @@ int OutputCode(ostream *Out, bool Cmnts, const string & CharSet, StringIntSet_t
unsigned int Len = ((NodeData.size() + 7) / 8);
OutputSize += Len;
x = 999;
- *Out << "static unsigned char WordEndBits[" << Len << "] =\n{";
+ *Out << "static const unsigned char WordEndBits[" << Len << "] =\n{";
Index = 0;
unsigned int v = 0;
unsigned int y = 0;
diff --git a/zxcvbn.c b/zxcvbn.c
index 95aa88f..f6d843b 100644
--- a/zxcvbn.c
+++ b/zxcvbn.c
@@ -1228,7 +1228,7 @@ static void SpatialMatch(ZxcMatch_t **Result, const uint8_t *Passwd, int Start,
/* The possible date formats ordered by length (d for day, m for month, */
/* y for year, ? for separator) */
-static const char *Formats[] =
+static const char * const Formats[] =
{
"yyyy",
"d?m?yy",
--
2.49.0

View File

@ -15,9 +15,12 @@ $(eval $(call gb_UnpackedTarball_set_patchlevel,zxcvbn-c,2))
# * external/zxcvbn-c/0001-There-is-no-std-basic_string-int.patch.1 sent upstream as
# <https://github.com/tsyrogit/zxcvbn-c/pull/31> "There is no std::basic_string<int>":
# * external/zxcvbn-c/0001-use-const-for-these-arrays.patch.1 sent upstream as
# <https://github.com/tsyrogit/zxcvbn-c/pull/37> "use const for these arrays":
$(eval $(call gb_UnpackedTarball_add_patches,zxcvbn-c,\
external/zxcvbn-c/zxcvbn-c-2.5-do-not-use-stdafx.patch \
external/zxcvbn-c/0001-There-is-no-std-basic_string-int.patch.1 \
external/zxcvbn-c/0001-use-const-for-these-arrays.patch.1 \
))
# vim: set noet sw=4 ts=4: