Skip to content

Commit

Permalink
Fixed bug in verifyPath() that was breaking PHYSFS_setSaneConfig() an…
Browse files Browse the repository at this point in the history
…d other

 corner cases.
  • Loading branch information
icculus committed Aug 20, 2005
1 parent 7b41816 commit bbb0cab
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG
Expand Up @@ -2,6 +2,8 @@
* CHANGELOG.
*/

08202005 - Fixed bug in verifyPath() that was breaking PHYSFS_setSaneConfig()
and other corner cases.
07242005 - Patched to compile on BeOS.
07232005 - Fixed bug in zip archiver (thanks, J�rg Walter!).
More minor OS/2 tweaks. Updated zlib to 1.2.3, which properly
Expand Down
13 changes: 7 additions & 6 deletions physfs.c
Expand Up @@ -1107,7 +1107,7 @@ int PHYSFS_setSaneConfig(const char *organization, const char *appName,

BAIL_IF_MACRO(!initialized, ERR_NOT_INITIALIZED, 0);

/* set write dir... */
/* set write dir... */
str = (char *) allocator.Malloc(
strlen(userdir) + (strlen(organization) * 2) +
(strlen(appName) * 2) + (strlen(dirsep) * 3) + 2);
Expand Down Expand Up @@ -1325,12 +1325,14 @@ static int verifyPath(DirHandle *h, char **_fname, int allowMissing)
{
while (1)
{
int rc = 0;
end = strchr(start, '/');
if (end != NULL)
*end = '\0';

if (h->funcs->isSymLink(h->opaque, fname, &retval))
BAIL_MACRO(ERR_SYMLINK_DISALLOWED, 0); /* insecure. */
if (end != NULL) *end = '\0';
rc = h->funcs->isSymLink(h->opaque, fname, &retval);
if (end != NULL) *end = '/';

BAIL_IF_MACRO(rc, ERR_SYMLINK_DISALLOWED, 0); /* insecure. */

/* break out early if path element is missing. */
if (!retval)
Expand All @@ -1348,7 +1350,6 @@ static int verifyPath(DirHandle *h, char **_fname, int allowMissing)
if (end == NULL)
break;

*end = '/';
start = end + 1;
} /* while */
} /* if */
Expand Down

0 comments on commit bbb0cab

Please sign in to comment.