[Crosstoolchain-logs] [device-tree-compiler] 28/58: libfdt: Remove undefined behaviour setting empty properties

Vagrant Cascadian vagrant at moszumanska.debian.org
Mon Sep 25 16:23:47 UTC 2017


This is an automated email from the git hooks/post-receive script.

vagrant pushed a commit to branch debian/master
in repository device-tree-compiler.

commit 69a1bd6ad3f9272b3db36e6415864a1fb6af4b9d
Author: David Gibson <david at gibson.dropbear.id.au>
Date:   Fri Feb 24 10:51:05 2017 +1100

    libfdt: Remove undefined behaviour setting empty properties
    
    The standard way of setting an empty property using libfdt is:
        fdt_setprop(fdt, nodeoffset, propname, NULL, 0);
    However, the implementation of this includes an unconditional:
         memcpy(prop->data, NULL, 0);
    Which although it will be a no-op (which is what we want) on many platforms
    is technically undefined behaviour.  Correct this, so that when passing
    a 0 length, passing a NULL pointer as the value to fdt_setprop() is
    definitely safe.  This should quiet static checkers which complain about
    this.
    
    Signed-off-by: David Gibson <david at gibson.dropbear.id.au>
---
 libfdt/fdt_rw.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libfdt/fdt_rw.c b/libfdt/fdt_rw.c
index 2eed4f5..3fd5847 100644
--- a/libfdt/fdt_rw.c
+++ b/libfdt/fdt_rw.c
@@ -283,7 +283,8 @@ int fdt_setprop(void *fdt, int nodeoffset, const char *name,
 	if (err)
 		return err;
 
-	memcpy(prop->data, val, len);
+	if (len)
+		memcpy(prop->data, val, len);
 	return 0;
 }
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/crosstoolchain/device-tree-compiler.git



More information about the Crosstoolchain-logs mailing list