changeset 13376:c3f168efd1e4

1046 wcsxfrm(3C) crashes when len arg is 0 Reviewed by: Robert Gordon <rbg@openrbg.com> Reviewed by: Jason King <jason.brian.king@gmail.com> Reviewed by: Garrett D'Amore <garrett@nexenta.com> Approved by: Albert Lee <trisk@nexenta.com>
author Gordon Ross <gwr@nexenta.com>
date Thu, 19 May 2011 13:45:25 -0400
parents 5e6d930c0c9b
children d89753efabc8
files usr/src/lib/libc/port/locale/wcsxfrm.c
diffstat 1 files changed, 3 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/usr/src/lib/libc/port/locale/wcsxfrm.c	Tue May 17 12:36:01 2011 -0400
+++ b/usr/src/lib/libc/port/locale/wcsxfrm.c	Thu May 19 13:45:25 2011 -0400
@@ -1,5 +1,5 @@
 /*
- * Copyright 2010 Nexenta Systems, Inc.  All rights reserved.
+ * Copyright 2011 Nexenta Systems, Inc.  All rights reserved.
  * Copyright (c) 1995 Alex Tatmanjants <alex@elvisti.kiev.ua>
  *		at Electronni Visti IA, Kiev, Ukraine.
  *			All rights reserved.
@@ -55,7 +55,7 @@
 	/* Add null termination at the correct location. */
 	if (len > slen) {
 		dest[slen] = 0;
-	} else if (len) {
+	} else if (len != 0) {
 		dest[len-1] = 0;
 	}
 
@@ -65,7 +65,7 @@
 	slen = wcslen(src);
 	if (slen < len)
 		(void) wcscpy(dest, src);
-	else {
+	else if (len != 0) {
 		(void) wcsncpy(dest, src, len - 1);
 		dest[len - 1] = L'\0';
 	}