Flexible I/O Tester development
 help / color / mirror / Atom feed
From: majianpeng <majianpeng@gmail.com>
To: Jens Axboe <JAxboe@fusionio.com>
Cc: fio <fio@vger.kernel.org>
Subject: [PATCH] fix  an overflowing.
Date: Thu, 10 Jan 2013 04:37:17 -0700	[thread overview]
Message-ID: <201301101937119708856@gmail.com> (raw)

Because nr_files and new_size are not same types.It can cause new_size
less than zero.Then realloc will be failed.

Signed-off-by: Jianpeng Ma <majianpeng@gmail.com>
---
 filesetup.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/filesetup.c b/filesetup.c
index 324e9a6..c55ff3f 100644
--- a/filesetup.c
+++ b/filesetup.c
@@ -1074,7 +1074,7 @@ int add_file(struct thread_data *td, const char *fname)
 	fio_file_reset(f);
 
 	if (td->files_size <= td->files_index) {
-		int new_size = td->o.nr_files + 1;
+		unsigned int new_size = td->o.nr_files + 1;
 
 		dprint(FD_FILE, "resize file array to %d files\n", new_size);
 		td->files = realloc(td->files, new_size * sizeof(f));
-- 
1.7.9.5

             reply	other threads:[~2013-01-10 11:37 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-01-10 11:37 majianpeng [this message]
2013-01-10 12:18 ` [PATCH] fix an overflowing Jens Axboe

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=201301101937119708856@gmail.com \
    --to=majianpeng@gmail.com \
    --cc=JAxboe@fusionio.com \
    --cc=fio@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