All of lore.kernel.org
 help / color / mirror / Atom feed
From: Mauro Carvalho Chehab <mchehab@redhat.com>
To: Linux Media Mailing List <linux-media@vger.kernel.org>,
	wk <handygewinnspiel@gmx.de>
Subject: [PATCH dvb-apps] Avoid buffer overflow with UTF-8 32-bit strings
Date: Tue, 12 Apr 2011 20:46:08 -0300	[thread overview]
Message-ID: <4DA4E440.7090008@redhat.com> (raw)

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 */

                 reply	other threads:[~2011-04-12 23:46 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4DA4E440.7090008@redhat.com \
    --to=mchehab@redhat.com \
    --cc=handygewinnspiel@gmx.de \
    --cc=linux-media@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.