Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4886519pxj; Wed, 12 May 2021 15:42:45 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwyHKttV7iFBSMiK5n/m7P+TGyhcPKVR5uN/uPwDB1PETp7gZm6FjL8L/wr/xn6uxUQtqWo X-Received: by 2002:a17:907:7634:: with SMTP id jy20mr40173917ejc.553.1620859365715; Wed, 12 May 2021 15:42:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620859365; cv=none; d=google.com; s=arc-20160816; b=QF68IgkwAzbT1HAYIxqTZtWIOwD0v+eCjjVD4QKkx6L+Qre+GThaBhnliQAQrdJzU0 Q0E06V+N7/HgT4C711wkRcyS2v/2jCz7oaIzraJ4U1qvQGiueHjzpvQP1oWBZzCfievj 0jRQHgWBtj/N2hQOSvDYkaOR01BtriDUa0/ngwrw7Fo5pyZVmwh1wyLr/q/3Z07eC09M n7cL6st8ghhkor8Jk/+foVstEfxeodnEmauVInwwqquzvD4rETB47/Z91fYypVhcCB3k Ix1CLzzteQ6KZfO6u1qvo7BI44mfRZcayecfivQfKm0Nr7btQb81hOuKNXzALmNNwT8T 3Klg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :organization:message-id:subject:to:from:date:dkim-signature; bh=ECiZex0mV5Oxaxt6S04kmD8mU2S1vLa1Q2/gouDDESI=; b=xNYnB9FASPa3qaMpHA5g3rxjeWtfQl6Vdss50DHjV9iB1VW6mnuyVNxeflA4Kf/xXl 3qBvb1HB4Gi/M3OSmwlLpum4vmXOsfKjqPKvvPv7Tr+cA7FUTBzIoAZExHgfaM0Go4PJ EsunS7TZSayU2YHVyYhNTnA8WGJOtFOYptoU9HNkl9i++1Lb+M3iRkikx4abl/qZNyXJ mWGwPWa3Go6G+xQsUuu6+kbxmSCv3Zb30ewKAaHdICo6bm/OwWqJd95vJd4UvAyhwZfL dd9s+pmbruw6jCp1nrSK3jFZaHqBCDY4y/fVmWaQ6f3fENdYKPtqTi5DXYen0IfDUvn+ /khw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=jExmYDJi; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cx8si850765edb.100.2021.05.12.15.42.23; Wed, 12 May 2021 15:42:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=jExmYDJi; spf=pass (google.com: domain of linux-bluetooth-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237416AbhELWl3 (ORCPT + 99 others); Wed, 12 May 2021 18:41:29 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:25288 "EHLO us-smtp-delivery-124.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1392199AbhELVgw (ORCPT ); Wed, 12 May 2021 17:36:52 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1620855343; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=ECiZex0mV5Oxaxt6S04kmD8mU2S1vLa1Q2/gouDDESI=; b=jExmYDJiYjCAK5JWKk5+o+z2TuqMecET5MOd2GVYt4u3B3btdqhICmifa++p8ZoMvvCvaT voD3jFmBxjNWOOh/k63Yb7iswxMj5GDZjE/Y/mSmgogV7lNOFyp0l4q62L5yHbR2sYg4xN XYbf54Cfiune3umeEHPP/J0InAlF3tk= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-244-nHaG0abqMEePbTVuzjrcpQ-1; Wed, 12 May 2021 17:35:41 -0400 X-MC-Unique: nHaG0abqMEePbTVuzjrcpQ-1 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id CE042801817 for ; Wed, 12 May 2021 21:35:40 +0000 (UTC) Received: from ivy-bridge (ovpn-112-130.rdu2.redhat.com [10.10.112.130]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8739719D9F for ; Wed, 12 May 2021 21:35:40 +0000 (UTC) Date: Wed, 12 May 2021 17:36:07 -0400 From: Steve Grubb To: linux-bluetooth@vger.kernel.org Subject: [Bluez PATCH 2/6] Fix leaks in obex Message-ID: <20210512173607.31b2b63d@ivy-bridge> Organization: Red Hat MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org In filesystem, g_file_get_contents allocates fresh memory. Use it instead of making a new copy of it. That saves having to free buf later. Destination was missed on an error path as is mld. Signed-off-by: Steve Grubb --- obexd/plugins/filesystem.c | 2 +- obexd/plugins/ftp.c | 8 ++++++-- obexd/plugins/messages-dummy.c | 1 + 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/obexd/plugins/filesystem.c b/obexd/plugins/filesystem.c index 09bff8ad0..44e3cf3d2 100644 --- a/obexd/plugins/filesystem.c +++ b/obexd/plugins/filesystem.c @@ -415,7 +415,7 @@ static void *capability_open(const char *name, int oflag, mode_t mode, goto fail; } - object->buffer = g_string_new(buf); + object->buffer = buf; if (size) *size = object->buffer->len; diff --git a/obexd/plugins/ftp.c b/obexd/plugins/ftp.c index 259bfcae2..4b04bab06 100644 --- a/obexd/plugins/ftp.c +++ b/obexd/plugins/ftp.c @@ -386,8 +386,10 @@ static int ftp_copy(struct ftp_session *ftp, const char *name, ret = verify_path(destdir); g_free(destdir); - if (ret < 0) + if (ret < 0) { + g_free(destination); return ret; + } source = g_build_filename(ftp->folder, name, NULL); @@ -424,8 +426,10 @@ static int ftp_move(struct ftp_session *ftp, const char *name, ret = verify_path(destdir); g_free(destdir); - if (ret < 0) + if (ret < 0) { + g_free(destination); return ret; + } source = g_build_filename(ftp->folder, name, NULL); diff --git a/obexd/plugins/messages-dummy.c b/obexd/plugins/messages-dummy.c index 34199fa05..e37b52df6 100644 --- a/obexd/plugins/messages-dummy.c +++ b/obexd/plugins/messages-dummy.c @@ -488,6 +488,7 @@ int messages_get_messages_listing(void *session, const char *name, int err = -errno; DBG("fopen(): %d, %s", -err, strerror(-err)); g_free(path); + g_free(mld); return -EBADR; } } -- 2.31.1