linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Gregor Jasny <gjasny@googlemail.com>
To: tskd08@gmail.com, linux-media@vger.kernel.org
Cc: m.chehab@samsung.com
Subject: Re: [PATCH v3 6/7] v4l-utils/dvb: add COUNTRY property
Date: Sun, 02 Nov 2014 11:14:31 +0100	[thread overview]
Message-ID: <54560407.8080603@googlemail.com> (raw)
In-Reply-To: <1414761224-32761-7-git-send-email-tskd08@gmail.com>

Hello,

Hello Coverity detected that dvb_guess_user_country introduces a
resource leak (CID 1250445).

On 31/10/14 14:13, tskd08@gmail.com wrote:
> +enum dvb_country_t dvb_guess_user_country(void)
> +{
> +	char * buf, * pch, * pbuf;
> +	unsigned cat;
> +	enum dvb_country_t id = COUNTRY_UNKNOWN;
> +
> +	for (cat = 0; cat < sizeof(cats)/sizeof(cats[0]); cat++) {
> +
> +		// the returned char * should be "C", "POSIX" or something valid.
> +		// If valid, we can only *guess* which format is returned.
> +		// Assume here something like "de_DE.iso8859-1@euro" or "de_DE.utf-8"
> +		buf = secure_getenv(cats[cat]);
> +		if (! buf || strlen(buf) < 2)
> +			continue;
> +
> +		buf = strdup(buf);
> +		pbuf= buf;
> +
> +		if (! strncmp(buf, "POSIX", MIN(strlen(buf), 5)) ||
> +		    ! (strncmp(buf, "en", MIN(strlen(buf), 2)) && !isalpha(buf[2])) )
> +			continue;
> +
> +		// assuming 'language_country.encoding@variant'
> +
> +		// country after '_', if given
> +		if ((pch = strchr(buf, '_')))
> +			pbuf = pch + 1;
> +
> +		// remove all after '@', including '@'
> +		if ((pch = strchr(pbuf, '@')))
> +			*pch = 0;
> +
> +		// remove all after '.', including '.'
> +		if ((pch = strchr(pbuf, '.')))
> +			*pch = 0;
> +
> +		if (strlen(pbuf) == 2)
> +			id = dvb_country_a2_to_id(pbuf);
> +		free(buf);
> +		if (id != COUNTRY_UNKNOWN)
> +			return id;
> +	}
> +
> +	return COUNTRY_UNKNOWN;
> +}

pbuf / buf may get leaked due to the continue statement.

Could you please post a patch?

Thanks,
Gregor

  reply	other threads:[~2014-11-02 10:14 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-10-31 13:13 [PATCH v3 0/7] v4l-utils/libdvbv5,dvb: add support for ISDB-S tskd08
2014-10-31 13:13 ` [PATCH v3 1/7] v4l-utils/libdvbv5, dvbv5-scan: generalize channel duplication check tskd08
2014-10-31 13:13 ` [PATCH v3 2/7] v4l-utils/libdvbv5: add as many channels as possible in scanning DVB-T2 tskd08
2014-10-31 13:13 ` [PATCH v3 3/7] v4l-utils/libdvbv5: wrong frequency in the output of satellite delsys scans tskd08
2014-10-31 13:13 ` [PATCH v3 4/7] v4l-utils/libdvbv5: add support for ISDB-S tuning tskd08
2014-10-31 13:13 ` [PATCH v3 5/7] v4l-utils/libdvbv5: add support for ISDB-S scanning tskd08
2014-10-31 13:13 ` [PATCH v3 6/7] v4l-utils/dvb: add COUNTRY property tskd08
2014-11-02 10:14   ` Gregor Jasny [this message]
2014-10-31 13:13 ` [PATCH v3 7/7] v4l-utils/libdvbv5: add gconv module for the text conversions of ISDB-S/T tskd08
2014-10-31 19:47   ` Mauro Carvalho Chehab
2014-11-01 11:37     ` Akihiro TSUKADA
2014-11-01 11:40   ` [PATCH v4] " tskd08
2014-11-02 14:17     ` Gregor Jasny
2014-11-02 15:49       ` Akihiro TSUKADA
2014-11-05 13:06     ` [PATCH v5] v4l-utils/libdvbv5: move gconv modules to contrib and autotoolize tskd08

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=54560407.8080603@googlemail.com \
    --to=gjasny@googlemail.com \
    --cc=linux-media@vger.kernel.org \
    --cc=m.chehab@samsung.com \
    --cc=tskd08@gmail.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).