summaryrefslogtreecommitdiff
path: root/Build/source/texk/upmendex/sort.c
diff options
context:
space:
mode:
authorTakuji Tanaka <ttk@t-lab.opal.ne.jp>2021-08-25 13:55:11 +0000
committerTakuji Tanaka <ttk@t-lab.opal.ne.jp>2021-08-25 13:55:11 +0000
commitdaad571338123052e0466c3e59cb183fe12aeb67 (patch)
tree385437f1898a6b2b6fc5a54c415f97ea64342958 /Build/source/texk/upmendex/sort.c
parent0052fcfc5c7b6a85b5f9cb128c299effd52c6ebb (diff)
upmendex: initialize string, check malformed input
git-svn-id: svn://tug.org/texlive/trunk@60319 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Build/source/texk/upmendex/sort.c')
-rw-r--r--Build/source/texk/upmendex/sort.c23
1 files changed, 16 insertions, 7 deletions
diff --git a/Build/source/texk/upmendex/sort.c b/Build/source/texk/upmendex/sort.c
index e3a47c12b72..38b64feeebc 100644
--- a/Build/source/texk/upmendex/sort.c
+++ b/Build/source/texk/upmendex/sort.c
@@ -17,7 +17,7 @@ void wsort(struct index *ind, int num)
{
int i,order;
UErrorCode status;
- UChar rules[STYBUFSIZE];
+ UChar rules[STYBUFSIZE] = {'\0'};
for (order=1,i=0;;i++) {
switch (character_order[i]) {
@@ -324,10 +324,11 @@ static int get_charset_juncture(UChar *str)
}
}
-static int unescape(const unsigned char *src, UChar *dist)
+static int unescape(const unsigned char *src, UChar *dest)
{
- int i,j,k;
+ int i,j,k,ret;
char tmp[STYBUFSIZE];
+ UErrorCode status;
for (i=j=0;i<STYBUFSIZE;i++) {
if (src[i]=='\0') {
@@ -336,15 +337,23 @@ static int unescape(const unsigned char *src, UChar *dist)
else if (src[i]< 0x80 && (src[i+1]>=0x80 || src[i+1]=='\0')) {
strncpy(tmp,(char *)&src[j],i-j+1);
tmp[i-j+1]='\0';
- k=u_strlen(dist);
- u_unescape(tmp, &dist[k], STYBUFSIZE-k);
+ k=u_strlen(dest);
+ ret=u_unescape(tmp, &dest[k], STYBUFSIZE-k);
+ if (ret==0) {
+ verb_printf(efp, "\n[ICU] Escape sequence in input seems malformed.\n");
+ exit(254);
+ }
j=i+1;
}
else if (src[i]>=0x80 && (src[i+1]< 0x80 || src[i+1]=='\0')) {
strncpy(tmp,(char *)&src[j],i-j+1);
tmp[i-j+1]='\0';
- k=u_strlen(dist);
- multibyte_to_widechar(&dist[k], STYBUFSIZE-k, tmp);
+ k=u_strlen(dest);
+ u_strFromUTF8(&dest[k], STYBUFSIZE-k, NULL, tmp, -1, &status);
+ if (U_FAILURE(status)) {
+ verb_printf(efp, "\n[ICU] Input string seems malformed.: %s\n", u_errorName(status));
+ exit(254);
+ }
j=i+1;
}
}