aboutsummaryrefslogtreecommitdiffstats
path: root/makewrappers
diff options
context:
space:
mode:
authorPeter Seebach <peter.seebach@windriver.com>2012-02-02 11:45:42 -0600
committerPeter Seebach <peter.seebach@windriver.com>2012-02-06 12:17:00 -0600
commit2b43a1b32f47df5aa442a1d579b0c8801389cff0 (patch)
treeb5aea361004115706f970a52869addef7b8ed81a /makewrappers
parent17c2233f93692f79684792750001ee6d13e03925 (diff)
downloadpseudo-2b43a1b32f47df5aa442a1d579b0c8801389cff0.tar.gz
pseudo-2b43a1b32f47df5aa442a1d579b0c8801389cff0.tar.bz2
pseudo-2b43a1b32f47df5aa442a1d579b0c8801389cff0.zip
Fix *at() function interface holes
1. Fix *at() where dirfd is obtained through dirfd(DIR *). The dirfd(DIR *) interface allows you to get the fd for a DIR *, meaning you can use it with openat(), meaning you can need its path. This causes a segfault. Also fixed the base_path code not to segfault in that case, but first fix the underlying problem. 2. Implement renameat() After three long years, someone tried to use this. This was impossibly hard back when pseudo was written, because there was only one dirfd provided for. Thing is, now, the canonicalization happens in wrapfuncs, so a small tweak to makewrappers to recognize that oldpath should use olddirfd if it exists is enough to get us fully canonicalized paths when needed.
Diffstat (limited to 'makewrappers')
-rwxr-xr-xmakewrappers17
1 files changed, 12 insertions, 5 deletions
diff --git a/makewrappers b/makewrappers
index 20bbf2b..23e48f7 100755
--- a/makewrappers
+++ b/makewrappers
@@ -211,12 +211,13 @@ class Function:
self.flags = '0'
self.port = port
self.directory = ''
- self.version = 'NULL'
+ self.version = 'NULL'
# On Darwin, some functions are SECRETLY converted to foo$INODE64
# when called. So we have to look those up for real_*
self.inode64 = None
self.real_func = None
self.paths_to_munge = []
+ self.specific_dirfds = {}
self.hand_wrapped = None
# used for the copyright date when creating stub functions
self.date = datetime.date.today().year
@@ -239,6 +240,7 @@ class Function:
# * If the arg has a name ending in 'path', we will canonicalize it.
# * If the arg is named 'dirfd' or 'flags', it becomes the default
# values for the dirfd and flags arguments when canonicalizing.
+ # * If the name ends in dirfd, we do the same fancy stuff.
# * Note that the "comments" field (/* ... */ after the decl) can
# override the dirfd/flags values.
self.args = ArgumentList(bits.group(2))
@@ -246,11 +248,13 @@ class Function:
# ignore varargs, they never get these special treatments
if arg.vararg:
pass
- elif arg.name == 'dirfd':
+ elif arg.name.endswith('dirfd'):
+ if len(arg.name) > 5:
+ self.specific_dirfds[arg.name[:-5]] = True
self.dirfd = 'dirfd'
elif arg.name == 'flags':
self.flags = 'flags'
- elif arg.name[-4:] == 'path':
+ elif arg.name.endswith('path'):
self.paths_to_munge.append(arg.name)
# pick default values
@@ -325,9 +329,12 @@ class Function:
"""create/allocate canonical paths"""
alloc_paths = []
for path in self.paths_to_munge:
+ prefix = path[:-4]
+ if prefix not in self.specific_dirfds:
+ prefix = ''
alloc_paths.append(
- "%s = pseudo_root_path(__func__, __LINE__, %s, %s, %s);" %
- (path, self.dirfd, path, self.flags))
+ "%s = pseudo_root_path(__func__, __LINE__, %s%s, %s, %s);" %
+ (path, prefix, self.dirfd, path, self.flags))
return "\n\t\t\t".join(alloc_paths)
def free_paths(self):