Skip to contentSkip to conversation

smbfs: Read buffer overflow

PATCH In review Roel Kluin 2 participants 2 messages Jul 23, 2009 – Jul 24, 2009

lore
Share & tools
lore

Roel Kluin

author
#0 lore raw

PATCH 1/1 smbfs: Read buffer overflow

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]

---
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,

fs/smbfs/proc.c +1 -1
index 9468168..71c29b6 100644
@@ -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;
 	}
#1 lore raw
Quoted 16 lines · On Thu, 23 Jul 2009 17:48:49 +0200 Roel Kluin <[email protected]> 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]

---
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,

fs/smbfs/proc.c +0 -0
index 9468168..71c29b6 100644

fs/smbfs/proc.c date_unix2dos(struct smb_sb_info *server, · line 515

Quoted 8 lines
fs/smbfs/proc.c +1 -1
@@ -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.