aboutsummaryrefslogtreecommitdiffstats
path: root/lib/bb/utils.py
diff options
context:
space:
mode:
authorBenjamin Esquivel <benjamin.esquivel@linux.intel.com>2015-09-03 07:10:45 +0000
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-09-03 16:51:07 +0100
commit38dd27f7191da002a16c561be3790ce487045b01 (patch)
tree97b82213ae9341af7f12aa3e6f7e2d9524d6a8c4 /lib/bb/utils.py
parent85a65d2b652c2ccc6cfb90fd8bc9048d0e72341e (diff)
downloadbitbake-38dd27f7191da002a16c561be3790ce487045b01.tar.gz
utils: Fix a potential error in movefile
bitbake utils' movefile is now prone to malform the destination file with duplicated file name strings. Fixing it to force a file name append iff the dest argument is a dir not a file name Signed-off-by: Benjamin Esquivel <benjamin.esquivel@linux.intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'lib/bb/utils.py')
-rw-r--r--lib/bb/utils.py9
1 files changed, 6 insertions, 3 deletions
diff --git a/lib/bb/utils.py b/lib/bb/utils.py
index 5eec78733..b62985dd7 100644
--- a/lib/bb/utils.py
+++ b/lib/bb/utils.py
@@ -741,9 +741,12 @@ def movefile(src, dest, newmtime = None, sstat = None):
renamefailed = 1
if sstat[stat.ST_DEV] == dstat[stat.ST_DEV]:
try:
- # os.rename needs to know the destination path with file name
- destfile = os.path.join(dest, os.path.basename(src))
- os.rename(src, destfile)
+ # os.rename needs to know the dest path ending with file name
+ # so append the file name to a path only if it's a dir specified
+ srcfname = os.path.basename(src)
+ destpath = os.path.join(dest, srcfname) if os.path.isdir(dest) \
+ else dest
+ os.rename(src, destpath)
renamefailed = 0
except Exception as e:
if e[0] != errno.EXDEV: