Skip to content

Commit d9f37e6

Browse files
committed
Add checks for valid multibyte character length in UtfToLocal, LocalToUtf.
This is mainly to suppress "uninitialized variable" warnings from very recent versions of gcc. But it seems like a good robustness thing anyway, not to mention that we might someday decide to support 6-byte UTF8. Per report from Karol Trzcionka. No back-patch since there's no reason at the moment to think this is more than cosmetic.
1 parent e2bd904 commit d9f37e6

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