summaryrefslogtreecommitdiffstats
path: root/bitbake/lib
diff options
context:
space:
mode:
Diffstat (limited to 'bitbake/lib')
-rw-r--r--bitbake/lib/bb/fetch2/__init__.py8
-rw-r--r--bitbake/lib/bb/tests/fetch.py9
2 files changed, 16 insertions, 1 deletions
diff --git a/bitbake/lib/bb/fetch2/__init__.py b/bitbake/lib/bb/fetch2/__init__.py
index 06f1eb4e81..cd7362c44a 100644
--- a/bitbake/lib/bb/fetch2/__init__.py
+++ b/bitbake/lib/bb/fetch2/__init__.py
@@ -1420,7 +1420,13 @@ class FetchMethod(object):
1420 1420
1421 # If 'subdir' param exists, create a dir and use it as destination for unpack cmd 1421 # If 'subdir' param exists, create a dir and use it as destination for unpack cmd
1422 if 'subdir' in urldata.parm: 1422 if 'subdir' in urldata.parm:
1423 unpackdir = '%s/%s' % (rootdir, urldata.parm.get('subdir')) 1423 subdir = urldata.parm.get('subdir')
1424 if os.path.isabs(subdir):
1425 if not os.path.realpath(subdir).startswith(os.path.realpath(rootdir)):
1426 raise UnpackError("subdir argument isn't a subdirectory of unpack root %s" % rootdir, urldata.url)
1427 unpackdir = subdir
1428 else:
1429 unpackdir = os.path.join(rootdir, subdir)
1424 bb.utils.mkdirhier(unpackdir) 1430 bb.utils.mkdirhier(unpackdir)
1425 else: 1431 else:
1426 unpackdir = rootdir 1432 unpackdir = rootdir
diff --git a/bitbake/lib/bb/tests/fetch.py b/bitbake/lib/bb/tests/fetch.py
index d7c73dda02..0fd2c02163 100644
--- a/bitbake/lib/bb/tests/fetch.py
+++ b/bitbake/lib/bb/tests/fetch.py
@@ -508,6 +508,15 @@ class FetcherLocalTest(FetcherTest):
508 tree = self.fetchUnpack(['file://dir/subdir/e;subdir=bar']) 508 tree = self.fetchUnpack(['file://dir/subdir/e;subdir=bar'])
509 self.assertEqual(tree, ['bar/dir/subdir/e']) 509 self.assertEqual(tree, ['bar/dir/subdir/e'])
510 510
511 def test_local_absolutedir(self):
512 # Unpacking to an absolute path that is a subdirectory of the root
513 # should work
514 tree = self.fetchUnpack(['file://a;subdir=%s' % os.path.join(self.unpackdir, 'bar')])
515
516 # Unpacking to an absolute path outside of the root should fail
517 with self.assertRaises(bb.fetch2.UnpackError):
518 self.fetchUnpack(['file://a;subdir=/bin/sh'])
519
511class FetcherNetworkTest(FetcherTest): 520class FetcherNetworkTest(FetcherTest):
512 521
513 if os.environ.get("BB_SKIP_NETTESTS") == "yes": 522 if os.environ.get("BB_SKIP_NETTESTS") == "yes":