summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustus Winter <4winter@informatik.uni-hamburg.de>2014-02-21 22:03:30 +0100
committerJustus Winter <4winter@informatik.uni-hamburg.de>2014-02-21 22:03:30 +0100
commit796ff2ca000fa6a6e37df45875ba109ff26a003d (patch)
treeab518f221cb68853e7708c5b14ad41054aa3bb43
parentb5bce6c001ef2acec4201af422ad0115c932a362 (diff)
add fix-mig_strncpy.patch
-rw-r--r--debian/patches/fix-mig_strncpy.patch49
-rw-r--r--debian/patches/series1
2 files changed, 50 insertions, 0 deletions
diff --git a/debian/patches/fix-mig_strncpy.patch b/debian/patches/fix-mig_strncpy.patch
new file mode 100644
index 0000000..932e8b1
--- /dev/null
+++ b/debian/patches/fix-mig_strncpy.patch
@@ -0,0 +1,49 @@
+commit fbad2b61020cccb8afa26968690e02bb62d1cc78
+Author: Justus Winter <4winter@informatik.uni-hamburg.de>
+Date: Fri Feb 21 21:57:37 2014 +0100
+
+ kern: fix mig_strncpy
+
+ Previously, the function mig_strncpy would always zero-terminate the
+ destination string. Make mig_strncpy behave like mig_strncpy and
+ strncpy in the glibc. Also fix the implementation of mig_strncpy to
+ return the length of the written string to align the implementation
+ with the declaration in include/mach/mig_support.h.
+
+ * kern/ipc_mig.c (mig_strncpy): Do not zero-terminate the destination
+ string. Return length of destination string.
+
+diff --git a/kern/ipc_mig.c b/kern/ipc_mig.c
+index bbc38cf..a52dcb9 100644
+--- a/kern/ipc_mig.c
++++ b/kern/ipc_mig.c
+@@ -285,22 +285,23 @@ mig_put_reply_port(
+ *
+ * len - Length of destination buffer.
+ */
+-void mig_strncpy(dest, src, len)
++vm_size_t
++mig_strncpy(dest, src, len)
+ char *dest;
+ const char *src;
+ int len;
+ {
++ char *dest_ = dest;
+ int i;
+
+ if (len <= 0)
+- return;
++ return 0;
+
+- for (i=1; i<len; i++)
++ for (i=0; i<len; i++)
+ if (! (*dest++ = *src++))
+- return;
++ break;
+
+- *dest = '\0';
+- return;
++ return dest - dest_;
+ }
+
+ #define fast_send_right_lookup(name, port, abort) \
diff --git a/debian/patches/series b/debian/patches/series
index 3296a83..a32e260 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -4,3 +4,4 @@
60_bigmem.patch
70_dde.patch
protected_payload.patch
+fix-mig_strncpy.patch