* [PATCH] smbfs: Read buffer overflow
@ 2009-07-23 15:48 Roel Kluin
2009-07-24 23:49 ` Andrew Morton
0 siblings, 1 reply; 2+ messages in thread
From: Roel Kluin @ 2009-07-23 15:48 UTC (permalink / raw)
To: LKML, Andrew Morton
This function uses signed integers for the unix_date and local variables - if a
negative number is supplied and the leap-year condition is not met, month
will be 0, leading to a read of day_n[-1]
Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
---
This is the easiest way to prevent the buffer overflow, but it produces a date.
Maybe a magic date would be better? What should we choose?
Credits to Parfait and Nathan Keynes,
diff --git a/fs/smbfs/proc.c b/fs/smbfs/proc.c
index 9468168..71c29b6 100644
--- a/fs/smbfs/proc.c
+++ b/fs/smbfs/proc.c
@@ -509,7 +509,7 @@ date_unix2dos(struct smb_sb_info *server,
month = 2;
} else {
nl_day = (year & 3) || day <= 59 ? day : day - 1;
- for (month = 0; month < 12; month++)
+ for (month = 1; month < 12; month++)
if (day_n[month] > nl_day)
break;
}
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] smbfs: Read buffer overflow
2009-07-23 15:48 [PATCH] smbfs: Read buffer overflow Roel Kluin
@ 2009-07-24 23:49 ` Andrew Morton
0 siblings, 0 replies; 2+ messages in thread
From: Andrew Morton @ 2009-07-24 23:49 UTC (permalink / raw)
To: Roel Kluin; +Cc: linux-kernel, Zhaolei
On Thu, 23 Jul 2009 17:48:49 +0200
Roel Kluin <roel.kluin@gmail.com> wrote:
> This function uses signed integers for the unix_date and local variables - if a
> negative number is supplied and the leap-year condition is not met, month
> will be 0, leading to a read of day_n[-1]
>
> Signed-off-by: Roel Kluin <roel.kluin@gmail.com>
> ---
> This is the easiest way to prevent the buffer overflow, but it produces a date.
> Maybe a magic date would be better? What should we choose?
>
> Credits to Parfait and Nathan Keynes,
>
> diff --git a/fs/smbfs/proc.c b/fs/smbfs/proc.c
> index 9468168..71c29b6 100644
> --- a/fs/smbfs/proc.c
> +++ b/fs/smbfs/proc.c
> @@ -509,7 +509,7 @@ date_unix2dos(struct smb_sb_info *server,
> month = 2;
> } else {
> nl_day = (year & 3) || day <= 59 ? day : day - 1;
> - for (month = 0; month < 12; month++)
> + for (month = 1; month < 12; month++)
> if (day_n[month] > nl_day)
> break;
> }
Again, fixable by switching to the kernel/time/timeconv.c functions.
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2009-07-24 23:49 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-07-23 15:48 [PATCH] smbfs: Read buffer overflow Roel Kluin
2009-07-24 23:49 ` Andrew Morton
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox