linux-ext4.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: [PATCH] ext4: simple_strtol returns signed.
  2008-10-18 20:21 [PATCH] ext4: simple_strtol returns signed roel kluin
@ 2008-10-18 14:36 ` Theodore Tso
  2008-10-21  2:00   ` roel kluin
  0 siblings, 1 reply; 3+ messages in thread
From: Theodore Tso @ 2008-10-18 14:36 UTC (permalink / raw)
  To: roel kluin; +Cc: linux-ext4

On Sat, Oct 18, 2008 at 04:21:44PM -0400, roel kluin wrote:
> simple_strtol returns signed.

Actually the better fix is probably to change the use of
simple_strtol() to simple_strtoul().

						- Ted

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH] ext4: simple_strtol returns signed.
@ 2008-10-18 20:21 roel kluin
  2008-10-18 14:36 ` Theodore Tso
  0 siblings, 1 reply; 3+ messages in thread
From: roel kluin @ 2008-10-18 20:21 UTC (permalink / raw)
  To: tytso, linux-ext4

simple_strtol returns signed.

Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
---
diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 9b2b2bc..1789dec 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -3516,7 +3516,7 @@ static ssize_t ext4_ui_proc_write(struct file *file, const char __user *buf,
 {
 	unsigned int *p = PDE(file->f_path.dentry->d_inode)->data;
 	char str[32];
-	unsigned long value;
+	long value;
 
 	if (cnt >= sizeof(str))
 		return -EINVAL;


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] ext4: simple_strtol returns signed.
  2008-10-18 14:36 ` Theodore Tso
@ 2008-10-21  2:00   ` roel kluin
  0 siblings, 0 replies; 3+ messages in thread
From: roel kluin @ 2008-10-21  2:00 UTC (permalink / raw)
  To: Theodore Tso; +Cc: linux-ext4

simple_strtol returns signed, but a negative return values is lost when stored
in an unsigned. As suggested use simple_strtoul() instead. 

Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
---
Since p is dereferenced with the unsigned long return of simple_strtoul, I think
p should be a pointer to an unsigned long, am I wrong?

diff --git a/fs/ext4/super.c b/fs/ext4/super.c
index 9b2b2bc..0ab6cb4 100644
--- a/fs/ext4/super.c
+++ b/fs/ext4/super.c
@@ -3514,18 +3514,15 @@ static int ext4_ui_proc_open(struct inode *inode, struct file *file)
 static ssize_t ext4_ui_proc_write(struct file *file, const char __user *buf,
 			       size_t cnt, loff_t *ppos)
 {
-	unsigned int *p = PDE(file->f_path.dentry->d_inode)->data;
+	unsigned long *p = PDE(file->f_path.dentry->d_inode)->data;
 	char str[32];
-	unsigned long value;
 
 	if (cnt >= sizeof(str))
 		return -EINVAL;
 	if (copy_from_user(str, buf, cnt))
 		return -EFAULT;
-	value = simple_strtol(str, NULL, 0);
-	if (value < 0)
-		return -ERANGE;
-	*p = value;
+
+	*p = simple_strtoul(str, NULL, 0);
 	return cnt;
 }
 

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2008-10-20 20:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-10-18 20:21 [PATCH] ext4: simple_strtol returns signed roel kluin
2008-10-18 14:36 ` Theodore Tso
2008-10-21  2:00   ` roel kluin

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).