* [PATCH dvb-apps] Avoid buffer overflow with UTF-8 32-bit strings
@ 2011-04-12 23:46 Mauro Carvalho Chehab
0 siblings, 0 replies; only message in thread
From: Mauro Carvalho Chehab @ 2011-04-12 23:46 UTC (permalink / raw)
To: Linux Media Mailing List, wk
As Winfried <handygewinnspiel@gmx.de> pointed, me UTF-8 can have up to
32 bits.
Also, someone might want to convert data to UCS-4, So, the buffer need to
have 4 bytes per char, to be safe.
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
diff --git a/util/scan/scan.c b/util/scan/scan.c
--- a/util/scan/scan.c
+++ b/util/scan/scan.c
@@ -884,7 +884,7 @@ static void descriptorcpy(char **dest, c
* Destination length should be bigger. As the worse case seems to
* use 3 chars for one code, use it for destlen
*/
- destlen = len * 3;
+ destlen = len * 4;
*dest = malloc(destlen + 1);
/* Remove special chars */
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2011-04-12 23:46 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-04-12 23:46 [PATCH dvb-apps] Avoid buffer overflow with UTF-8 32-bit strings Mauro Carvalho Chehab
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox