linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alexey Dobriyan <adobriyan@gmail.com>
To: Andrew Morton <akpm@osdl.org>
Cc: "Sergey S. Kostyliov" <rathamahata@php4.ru>,
	linux-kernel@vger.kernel.org
Subject: [PATCH] befs: use strlcpy()
Date: Sun, 30 Oct 2005 04:18:17 +0300	[thread overview]
Message-ID: <20051030011817.GA32602@mipter.zuzino.mipt.ru> (raw)

Signed-off-by: Alexey Dobriyan <adobriyan@gmail.com>
---
	Looks like second strncpy() can fill symlink buffer without
	NUL-termination which would cause bad things later, though I
	may be wrong.

 fs/befs/btree.c    |    3 +--
 fs/befs/linuxvfs.c |    4 ++--
 2 files changed, 3 insertions(+), 4 deletions(-)

--- a/fs/befs/btree.c
+++ b/fs/befs/btree.c
@@ -503,10 +503,9 @@ befs_btree_read(struct super_block *sb, 
 		goto error_alloc;
 	};
 
-	strncpy(keybuf, keystart, keylen);
+	strlcpy(keybuf, keystart, keylen);
 	*value = fs64_to_cpu(sb, valarray[cur_key]);
 	*keysize = keylen;
-	keybuf[keylen] = '\0';
 
 	befs_debug(sb, "Read [%Lu,%d]: Key \"%.*s\", Value %Lu", node_off,
 		   cur_key, keylen, keybuf, *value);
--- linux-vanilla/fs/befs/linuxvfs.c
+++ linux-strlcpy/fs/befs/linuxvfs.c
@@ -381,8 +381,8 @@ befs_read_inode(struct inode *inode)
 	if (S_ISLNK(inode->i_mode) && !(befs_ino->i_flags & BEFS_LONG_SYMLINK)){
 		inode->i_size = 0;
 		inode->i_blocks = befs_sb->block_size / VFS_BLOCK_SIZE;
-		strncpy(befs_ino->i_data.symlink, raw_inode->data.symlink,
-			BEFS_SYMLINK_LEN);
+		strlcpy(befs_ino->i_data.symlink, raw_inode->data.symlink,
+			sizeof(befs_ino->i_data.symlink));
 	} else {
 		int num_blks;
 


             reply	other threads:[~2005-10-30  1:05 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-10-30  1:18 Alexey Dobriyan [this message]
2005-10-30 10:38 ` [PATCH] befs: use strlcpy() Andreas Schwab

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=20051030011817.GA32602@mipter.zuzino.mipt.ru \
    --to=adobriyan@gmail.com \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rathamahata@php4.ru \
    /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).