X-Git-Url: https://git.saurik.com/apple/hfs.git/blobdiff_plain/e4cc4424151bb40d5b692bd5de231b3283d1db36..refs/heads/master:/core/hfs_vnops.c diff --git a/core/hfs_vnops.c b/core/hfs_vnops.c index 237f071..cf6d106 100644 --- a/core/hfs_vnops.c +++ b/core/hfs_vnops.c @@ -5538,10 +5538,6 @@ hfs_vnop_symlink(struct vnop_symlink_args *ap) if (VTOVCB(dvp)->vcbSigWord != kHFSPlusSigWord) return (ENOTSUP); - /* Check for empty target name */ - if (ap->a_target[0] == 0) - return (EINVAL); - hfsmp = VTOHFS(dvp); len = strlen(ap->a_target); @@ -5569,6 +5565,9 @@ hfs_vnop_symlink(struct vnop_symlink_args *ap) goto out; } + if (!len) + goto out; + #if QUOTA (void)hfs_getinoquota(cp); #endif /* QUOTA */ @@ -6063,10 +6062,21 @@ hfs_vnop_readlink(struct vnop_readlink_args *ap) fp = VTOF(vp); /* Zero length sym links are not allowed */ - if (fp->ff_size == 0 || fp->ff_size > MAXPATHLEN) { + if (fp->ff_size > MAXPATHLEN) { error = EINVAL; goto exit; } + + /* + * If this is an empty symlink, we are done. The call to uiomove() is + * just for debug and diagnostics. + */ + if (fp->ff_size == 0) { + static uint8_t empty_str[] = {'\0'}; + + error = uiomove((caddr_t)empty_str, 0, ap->a_uio); + goto exit; + } /* Cache the path so we don't waste buffer cache resources */ if (fp->ff_symlinkptr == NULL) {