# HG changeset patch
# User Hollis Blanchard <hollisb@xxxxxxxxxx>
# Date 1171053801 21600
# Node ID 272291dacad45903a439471835769af233fc64e4
# Parent 4613ee57e9b35ac5e2b2f7efcc9b3963c1216075
[POWERPC][XEN] strlcpy() fallout.
- Implement strlcpy() for the dom0 firmware.
- Remove strncpy() from dom0 firmware.
- Correct buffer length in device tree copying.
Signed-off-by: Hollis Blanchard <hollisb@xxxxxxxxxx>
---
xen/arch/powerpc/of_handler/strncpy.c | 54 -------------------------------
xen/arch/powerpc/of-devtree.c | 2 -
xen/arch/powerpc/of_handler/Makefile | 2 -
xen/arch/powerpc/of_handler/strlcpy.c | 58 ++++++++++++++++++++++++++++++++++
4 files changed, 60 insertions(+), 56 deletions(-)
diff -r 4613ee57e9b3 -r 272291dacad4 xen/arch/powerpc/of-devtree.c
--- a/xen/arch/powerpc/of-devtree.c Wed Feb 07 18:53:33 2007 -0600
+++ b/xen/arch/powerpc/of-devtree.c Fri Feb 09 14:43:21 2007 -0600
@@ -358,7 +358,7 @@ static ofdn_t ofd_node_create(
n->on_io = 0;
n->on_pathlen = pathlen;
n->on_last = ofd_pathsplit_left(path, '/', pathlen);
- strlcpy(n->on_path, path, pathlen);
+ strlcpy(n->on_path, path, pathlen + 1);
return pos;
}
diff -r 4613ee57e9b3 -r 272291dacad4 xen/arch/powerpc/of_handler/Makefile
--- a/xen/arch/powerpc/of_handler/Makefile Wed Feb 07 18:53:33 2007 -0600
+++ b/xen/arch/powerpc/of_handler/Makefile Fri Feb 09 14:43:21 2007 -0600
@@ -27,5 +27,5 @@ obj-y += strcmp.o
obj-y += strcmp.o
obj-y += strlen.o
obj-y += strncmp.o
-obj-y += strncpy.o
+obj-y += strlcpy.o
obj-y += strnlen.o
diff -r 4613ee57e9b3 -r 272291dacad4 xen/arch/powerpc/of_handler/strlcpy.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/xen/arch/powerpc/of_handler/strlcpy.c Fri Feb 09 14:43:21 2007 -0600
@@ -0,0 +1,58 @@
+/*
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * Copyright IBM Corp. 2005, 2007
+ *
+ * Authors: Jimi Xenidis <jimix@xxxxxxxxxxxxxx>
+ * Hollis Blanchard <hollisb@xxxxxxxxxx>
+ */
+
+#include <xen/string.h>
+
+size_t
+strlcpy(char *dest, const char *src, size_t n)
+{
+ size_t ret;
+ char *dp;
+
+ /* cases to consider:
+ * dest is NULL, s is NULL;
+ * src is empty (0);
+ * src is not empty, less than n;
+ * src is not empty, equal to n;
+ * src is not empty, greater than n;
+ */
+
+ if (n <= 0) {
+ return 0;
+ }
+
+ dp = dest;
+
+ do {
+ *dp++ = *src;
+ --n;
+ ++src;
+ } while ((*src != '\0') && (n > 1));
+
+ ret = n;
+
+ /* clear remainder of buffer (if any); ANSI semantics */
+ while (n > 0) {
+ *dp++ = '\0';
+ --n;
+ }
+ return ret;
+}
diff -r 4613ee57e9b3 -r 272291dacad4 xen/arch/powerpc/of_handler/strncpy.c
--- a/xen/arch/powerpc/of_handler/strncpy.c Wed Feb 07 18:53:33 2007 -0600
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,54 +0,0 @@
-/*
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * Copyright (C) IBM Corp. 2005
- *
- * Authors: Jimi Xenidis <jimix@xxxxxxxxxxxxxx>
- */
-
-#include <xen/string.h>
-
-char *
-strncpy(char *dest, const char *src, size_t n)
-{
- char *dp;
-
- /* cases to consider:
- * dest is NULL, s is NULL;
- * src is empty (0);
- * src is not empty, less than n;
- * src is not empty, equal to n;
- * src is not empty, greater than n;
- */
-
- if (n <= 0) {
- return dest;
- }
-
- dp = dest;
-
- do {
- *dp++ = *src;
- --n;
- ++src;
- } while ((*src != '\0') && (n > 0));
-
- /* clear remainder of buffer (if any); ANSI semantics */
- while (n > 0) {
- *dp++ = '\0';
- --n;
- }
- return dest;
-}
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog
|