From patchwork Tue Sep 9 07:45:06 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miroslav Rezanina X-Patchwork-Id: 387195 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 955F914001A for ; Tue, 9 Sep 2014 17:45:41 +1000 (EST) Received: from localhost ([::1]:47984 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XRG7P-0006Nd-Re for incoming@patchwork.ozlabs.org; Tue, 09 Sep 2014 03:45:39 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46954) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XRG73-00064W-KV for qemu-devel@nongnu.org; Tue, 09 Sep 2014 03:45:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XRG6x-0004Dw-Fv for qemu-devel@nongnu.org; Tue, 09 Sep 2014 03:45:17 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60571) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XRG6x-0004Ds-16 for qemu-devel@nongnu.org; Tue, 09 Sep 2014 03:45:11 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s897j91i006885 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Tue, 9 Sep 2014 03:45:10 -0400 Received: from lws-ntb.brq.redhat.com (dhcp-27-208.brq.redhat.com [10.34.27.208]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s897j8O0022370 for ; Tue, 9 Sep 2014 03:45:09 -0400 From: mrezanin@redhat.com To: qemu-devel@nongnu.org Date: Tue, 9 Sep 2014 09:45:06 +0200 Message-Id: <1410248706-9769-1-git-send-email-mrezanin@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH] Prevent segmentation fault in case of relative resolve of uri X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Miroslav Rezanina It was possible to call strcmp with NULL argument, that can cause segmentation fault. Properly checking parameters to prevent this situation. Signed-off-by: Miroslav Rezanina --- util/uri.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/util/uri.c b/util/uri.c index e348c17..16c01d0 100644 --- a/util/uri.c +++ b/util/uri.c @@ -1985,7 +1985,8 @@ uri_resolve_relative (const char *uri, const char * base) val = g_strdup (uri); goto done; } - if (!strcmp(bas->path, ref->path)) { + if (bas->path != NULL && ref->path != NULL && + !strcmp(bas->path, ref->path)) { val = g_strdup(""); goto done; }