Linux bluetooth development
 help / color / mirror / Atom feed
From: Radoslaw Jablonski <radoslawjablonski@gmail.com>
To: linux-bluetooth@vger.kernel.org
Cc: Radoslaw Jablonski <radoslawjablonski@gmail.com>
Subject: [PATCH obexd 2/2] Add NULL-field checking in vcard_printf_address
Date: Mon, 10 Oct 2011 09:22:39 +0200	[thread overview]
Message-ID: <1318231359-3309-2-git-send-email-radoslawjablonski@gmail.com> (raw)
In-Reply-To: <1318231359-3309-1-git-send-email-radoslawjablonski@gmail.com>

Without that checking strlen(..) could be called with NULL
as param and this will result crash (in some scenarios
'field' may be NULL)
---
 plugins/vcard.c |    7 +++++--
 1 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/plugins/vcard.c b/plugins/vcard.c
index c0a33cb..dc20a77 100644
--- a/plugins/vcard.c
+++ b/plugins/vcard.c
@@ -680,8 +680,11 @@ static void vcard_printf_address(GString *vcards, uint8_t format,
 	for (l = address->fields; l; l = l->next) {
 		char *field = l->data;
 
-		set_escape(format, field_esc, field, LEN_MAX, strlen(field));
-		g_strlcat(fields, field_esc, len);
+		if (field) {
+			set_escape(format, field_esc, field, LEN_MAX,
+								strlen(field));
+			g_strlcat(fields, field_esc, len);
+		}
 
 		if (l->next)
 			/* not adding ';' after last addr field */
-- 
1.7.0.4


  reply	other threads:[~2011-10-10  7:22 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-10-10  7:22 [PATCH obexd 1/2] Add check for empty string in vcard_printf_fullname Radoslaw Jablonski
2011-10-10  7:22 ` Radoslaw Jablonski [this message]
2011-10-11 13:29 ` Johan Hedberg

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=1318231359-3309-2-git-send-email-radoslawjablonski@gmail.com \
    --to=radoslawjablonski@gmail.com \
    --cc=linux-bluetooth@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox