From: Andreas Dilger <adilger@dilger.ca>
To: Lukas Czerner <lczerner@redhat.com>
Cc: linux-ext4@vger.kernel.org
Subject: Re: [PATCH 2/4] e2fsck: use size_t instead of int in string_copy()
Date: Fri, 5 Jun 2020 15:26:01 -0600 [thread overview]
Message-ID: <1D928A6F-0C72-4943-A571-52300DDCE77B@dilger.ca> (raw)
In-Reply-To: <20200605081442.13428-2-lczerner@redhat.com>
[-- Attachment #1: Type: text/plain, Size: 1997 bytes --]
On Jun 5, 2020, at 2:14 AM, Lukas Czerner <lczerner@redhat.com> wrote:
>
> len argument in string_copy() is int, but it is used with malloc(),
> strlen(), strncpy() and some callers use sizeof() to pass value in. So
> it really ought to be size_t rather than int. Fix it.
>
> Signed-off-by: Lukas Czerner <lczerner@redhat.com>
Thanks, having good types makes it much easier to follow code logic.
There are still a bunch of places in e2fsprogs that are using "int" and
"long" for various blocks, counters, etc. that could use more precise
types. I did a bunch of cleanup when I reviewd all of the directory and
allocation code for 64-bit issues. It still lingers elsewhere, but every
fix improves the code a bit, if we keep an eye on other incoming changes.
Reviewed-by: Andreas Dilger <adilger@dilger.ca>
> ---
> e2fsck/e2fsck.h | 2 +-
> e2fsck/util.c | 2 +-
> 2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/e2fsck/e2fsck.h b/e2fsck/e2fsck.h
> index 9b2b9ce8..85f953b2 100644
> --- a/e2fsck/e2fsck.h
> +++ b/e2fsck/e2fsck.h
> @@ -627,7 +627,7 @@ extern void log_err(e2fsck_t ctx, const char *fmt, ...)
> extern void e2fsck_read_bitmaps(e2fsck_t ctx);
> extern void e2fsck_write_bitmaps(e2fsck_t ctx);
> extern void preenhalt(e2fsck_t ctx);
> -extern char *string_copy(e2fsck_t ctx, const char *str, int len);
> +extern char *string_copy(e2fsck_t ctx, const char *str, size_t len);
> extern int fs_proc_check(const char *fs_name);
> extern int check_for_modules(const char *fs_name);
> #ifdef RESOURCE_TRACK
> diff --git a/e2fsck/util.c b/e2fsck/util.c
> index d98b8e47..88e0ea8a 100644
> --- a/e2fsck/util.c
> +++ b/e2fsck/util.c
> @@ -135,7 +135,7 @@ void *e2fsck_allocate_memory(e2fsck_t ctx, unsigned long size,
> }
>
> char *string_copy(e2fsck_t ctx EXT2FS_ATTR((unused)),
> - const char *str, int len)
> + const char *str, size_t len)
> {
> char *ret;
>
> --
> 2.21.3
>
Cheers, Andreas
[-- Attachment #2: Message signed with OpenPGP --]
[-- Type: application/pgp-signature, Size: 873 bytes --]
next prev parent reply other threads:[~2020-06-05 21:26 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-06-05 8:14 [PATCH 1/4] e2fsck: remove unused variable 'new_array' Lukas Czerner
2020-06-05 8:14 ` [PATCH 2/4] e2fsck: use size_t instead of int in string_copy() Lukas Czerner
2020-06-05 21:26 ` Andreas Dilger [this message]
2020-10-01 20:43 ` Theodore Y. Ts'o
2020-06-05 8:14 ` [PATCH 3/4] e2fsck: use the right conversion specifier in e2fsck_allocate_memory() Lukas Czerner
2020-06-05 20:42 ` Andreas Dilger
2020-10-01 20:49 ` Theodore Y. Ts'o
2020-06-05 8:14 ` [PATCH 4/4] ext2fs: remove unused variable 'left' Lukas Czerner
2020-06-05 20:48 ` Andreas Dilger
2020-10-01 20:51 ` Theodore Y. Ts'o
2020-06-05 20:36 ` [PATCH 1/4] e2fsck: remove unused variable 'new_array' Andreas Dilger
2020-06-05 20:38 ` Andreas Dilger
2020-09-22 12:37 ` Lukas Czerner
2020-10-01 20:43 ` Theodore Y. Ts'o
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=1D928A6F-0C72-4943-A571-52300DDCE77B@dilger.ca \
--to=adilger@dilger.ca \
--cc=lczerner@redhat.com \
--cc=linux-ext4@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).