Skip to content

Commit 404d987

Browse files
committed
Add checks for valid multibyte character length in UtfToLocal, LocalToUtf.
This back-patches commit d9f37e6 into out-of-support branches, pursuant to newly-established project policy. The point is to suppress "uninitialized variable" warnings so that people building these branches needn't expend brain cells verifying that it's safe to ignore the warnings. Discussion: https://postgr.es/m/d0316012-ece7-7b7e-2d36-9c38cb77cb3b@enterprisedb.com
1 parent f24374b commit 404d987

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/backend/utils/mb/conv.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,11 @@ UtfToLocal(const unsigned char *utf, unsigned char *iso,
382382
iutf |= *utf++ << 8;
383383
iutf |= *utf++;
384384
}
385+
else
386+
{
387+
elog(ERROR, "unsupported character length %d", l);
388+
iutf = 0; /* keep compiler quiet */
389+
}
385390

386391
/*
387392
* first, try with combined map if possible
@@ -437,6 +442,11 @@ UtfToLocal(const unsigned char *utf, unsigned char *iso,
437442
iutf |= *utf++ << 8;
438443
iutf |= *utf++;
439444
}
445+
else
446+
{
447+
elog(ERROR, "unsupported character length %d", l);
448+
iutf = 0; /* keep compiler quiet */
449+
}
440450

441451
cutf[1] = iutf;
442452
cp = bsearch(cutf, cmap, size2,
@@ -546,6 +556,11 @@ LocalToUtf(const unsigned char *iso, unsigned char *utf,
546556
iiso |= *iso++ << 8;
547557
iiso |= *iso++;
548558
}
559+
else
560+
{
561+
elog(ERROR, "unsupported character length %d", l);
562+
iiso = 0; /* keep compiler quiet */
563+
}
549564

550565
p = bsearch(&iiso, map, size1,
551566
sizeof(pg_local_to_utf), compare2);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy