WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] [xen-unstable] libelf cannot rely on the strlcpy() BSD-i

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] [xen-unstable] libelf cannot rely on the strlcpy() BSD-ism.
From: Xen patchbot-unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Mon, 29 Jan 2007 08:15:09 -0800
Delivery-date: Mon, 29 Jan 2007 08:15:16 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User kfraser@xxxxxxxxxxxxxxxxxxxxx
# Date 1170071220 0
# Node ID 1b32e279ddef03cfbfcbdbd368a990f97fd84e19
# Parent  5d9b72e640e050cbe5a1e3677c4ca7cb2cd868c1
libelf cannot rely on the strlcpy() BSD-ism.
Make a private definition based on strncpy and strlen.
Signed-off-by: Keir Fraser <keir@xxxxxxxxxxxxx>
---
 xen/common/libelf/libelf-dominfo.c |   16 ++++++++--------
 xen/common/libelf/libelf-private.h |   10 ++++++++++
 2 files changed, 18 insertions(+), 8 deletions(-)

diff -r 5d9b72e640e0 -r 1b32e279ddef xen/common/libelf/libelf-dominfo.c
--- a/xen/common/libelf/libelf-dominfo.c        Mon Jan 29 10:55:20 2007 +0000
+++ b/xen/common/libelf/libelf-dominfo.c        Mon Jan 29 11:47:00 2007 +0000
@@ -128,16 +128,16 @@ int elf_xen_parse_note(struct elf_binary
     switch (type)
     {
     case XEN_ELFNOTE_LOADER:
-       strlcpy(parms->loader, str, sizeof(parms->loader));
+       elf_strlcpy(parms->loader, str, sizeof(parms->loader));
        break;
     case XEN_ELFNOTE_GUEST_OS:
-       strlcpy(parms->guest_os, str, sizeof(parms->guest_os));
+       elf_strlcpy(parms->guest_os, str, sizeof(parms->guest_os));
        break;
     case XEN_ELFNOTE_GUEST_VERSION:
-       strlcpy(parms->guest_ver, str, sizeof(parms->guest_ver));
+       elf_strlcpy(parms->guest_ver, str, sizeof(parms->guest_ver));
        break;
     case XEN_ELFNOTE_XEN_VERSION:
-       strlcpy(parms->xen_ver, str, sizeof(parms->xen_ver));
+       elf_strlcpy(parms->xen_ver, str, sizeof(parms->xen_ver));
        break;
     case XEN_ELFNOTE_PAE_MODE:
        if (0 == strcmp(str, "yes"))
@@ -224,13 +224,13 @@ int elf_xen_parse_guest_info(struct elf_
 
        /* strings */
        if (0 == strcmp(name, "LOADER"))
-           strlcpy(parms->loader, value, sizeof(parms->loader));
+           elf_strlcpy(parms->loader, value, sizeof(parms->loader));
        if (0 == strcmp(name, "GUEST_OS"))
-           strlcpy(parms->guest_os, value, sizeof(parms->guest_os));
+           elf_strlcpy(parms->guest_os, value, sizeof(parms->guest_os));
        if (0 == strcmp(name, "GUEST_VER"))
-           strlcpy(parms->guest_ver, value, sizeof(parms->guest_ver));
+           elf_strlcpy(parms->guest_ver, value, sizeof(parms->guest_ver));
        if (0 == strcmp(name, "XEN_VER"))
-           strlcpy(parms->xen_ver, value, sizeof(parms->xen_ver));
+           elf_strlcpy(parms->xen_ver, value, sizeof(parms->xen_ver));
        if (0 == strcmp(name, "PAE"))
        {
            if (0 == strcmp(value, "yes[extended-cr3]"))
diff -r 5d9b72e640e0 -r 1b32e279ddef xen/common/libelf/libelf-private.h
--- a/xen/common/libelf/libelf-private.h        Mon Jan 29 10:55:20 2007 +0000
+++ b/xen/common/libelf/libelf-private.h        Mon Jan 29 11:47:00 2007 +0000
@@ -20,6 +20,8 @@
 #define bswap_16(x) swab16(x)
 #define bswap_32(x) swab32(x)
 #define bswap_64(x) swab64(x)
+
+#define elf_strlcpy(d,s,c) strlcpy(d,s,c)
 
 #else /* !__XEN__ */
 
@@ -50,6 +52,14 @@
         xc_set_error(XC_INVALID_KERNEL, fmt , ## args );  \
        } while (0)
 
+/* SysV unices have no strlcpy/strlcat. */
+static inline size_t elf_strlcpy(char *dest, const char *src, size_t size)
+{
+    strncpy(dest, src, size-1);
+    dest[size-1] = '\0';
+    return strlen(src);
+}
+
 #endif
 
 #endif /* __LIBELF_PRIVATE_H_ */

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] [xen-unstable] libelf cannot rely on the strlcpy() BSD-ism., Xen patchbot-unstable <=