diff mbox

[linux-cifs-client,4/5] cifs: Fix buffer size in cifs_convertUCSpath and add a missing overrun check

Message ID 4A01758D.5060309@suse.de (mailing list archive)
State New, archived
Headers show

Commit Message

Suresh Jayaraman May 6, 2009, 11:33 a.m. UTC
From: Suresh Jayaraman <sjayaraman@suse.de>
Subject: Fix buffer size in cifs_convertUCSpath and add a missing overrun check

Reported-by: Jeff Layton <jlayton@redhat.com>
Signed-off-by: Suresh Jayaraman <sjayaraman@suse.de>
---
 fs/cifs/misc.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
diff mbox

Patch

Index: linux-2.6.29.2/fs/cifs/misc.c
===================================================================
--- linux-2.6.29.2.orig/fs/cifs/misc.c
+++ linux-2.6.29.2/fs/cifs/misc.c
@@ -691,14 +691,15 @@  cifs_convertUCSpath(char *target, const
 						NLS_MAX_CHARSET_SIZE);
 				if (len > 0) {
 					j += len;
-					continue;
+					goto overrun_chk;
 				} else {
 					target[j] = '?';
 				}
 		}
 		j++;
 		/* make sure we do not overrun callers allocated temp buffer */
-		if (j >= (2 * NAME_MAX))
+overrun_chk:
+		if (j >= UNICODE_NAME_MAX)
 			break;
 	}
 cUCS_out: