[PATCH dvb-apps] Avoid buffer overflow with UTF-8 32-bit strings

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



As Winfried <handygewinnspiel@xxxxxx> 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@xxxxxxxxxx>

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 */
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Input]     [Video for Linux]     [Gstreamer Embedded]     [Mplayer Users]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]
  Powered by Linux