linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jim Meyering <jim@meyering.net>
To: linux-btrfs@vger.kernel.org
Subject: [PATCH 1/4] mkfs: use strdup in place of strlen,malloc,strcpy sequence
Date: Fri, 20 Apr 2012 19:36:45 +0200	[thread overview]
Message-ID: <1334943408-6720-2-git-send-email-jim@meyering.net> (raw)
In-Reply-To: <1334943408-6720-1-git-send-email-jim@meyering.net>

From: Jim Meyering <meyering@redhat.com>

* mkfs.c (traverse_directory): No semantic change.
---
 mkfs.c |    3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/mkfs.c b/mkfs.c
index c531ef2..03239fb 100644
--- a/mkfs.c
+++ b/mkfs.c
@@ -911,8 +911,7 @@ static int traverse_directory(struct btrfs_trans_handle *trans,
 	/* Add list for source directory */
 	dir_entry = malloc(sizeof(struct directory_name_entry));
 	dir_entry->dir_name = dir_name;
-	dir_entry->path = malloc(strlen(dir_name) + 1);
-	strcpy(dir_entry->path, dir_name);
+	dir_entry->path = strdup(dir_name);

 	parent_inum = highest_inum + BTRFS_FIRST_FREE_OBJECTID;
 	dir_entry->inum = parent_inum;
-- 
1.7.10.208.gb4267


  reply	other threads:[~2012-04-20 17:36 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-04-20 17:36 btrfs-utils: minor buffer-overrun fixes Jim Meyering
2012-04-20 17:36 ` Jim Meyering [this message]
2012-04-20 18:36   ` [PATCH 1/4] mkfs: use strdup in place of strlen,malloc,strcpy sequence Josef Bacik
2012-04-20 17:36 ` [PATCH 2/4] restore: don't corrupt stack for a zero-length command-line argument Jim Meyering
2012-04-20 18:37   ` Josef Bacik
2012-04-20 18:40   ` Josef Bacik
2012-04-20 17:36 ` [PATCH 3/4] avoid strncpy-induced buffer overrun Jim Meyering
2012-04-20 18:42   ` Josef Bacik
2012-04-20 19:26     ` Jim Meyering
2012-04-20 17:36 ` [PATCH 4/4] mkfs: avoid heap-buffer-read-underrun for zero-length "size" arg Jim Meyering
2012-04-20 18:41   ` Josef Bacik

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=1334943408-6720-2-git-send-email-jim@meyering.net \
    --to=jim@meyering.net \
    --cc=linux-btrfs@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;
as well as URLs for NNTP newsgroup(s).