Fixed buffer overflow in CD-ROM detection code.

This commit is contained in:
Ryan C. Gordon 2002-06-29 22:25:57 +00:00
parent 4dce6eed3d
commit 3df9dda733
2 changed files with 9 additions and 9 deletions

View File

@ -119,7 +119,7 @@ char **__PHYSFS_platformDetectAvailableCDs(void)
hpbr.volumeParam.ioVolIndex = 0;
if (PBHGetVInfoSync(&hpbr) == noErr)
{
char **tmp = realloc(retval, sizeof (char *) * cd_count + 1);
char **tmp = realloc(retval, sizeof (char *) * (cd_count + 1));
if (tmp)
{
char *str = (char *) malloc(volName[0] + 1);

View File

@ -91,15 +91,15 @@ char **__PHYSFS_platformDetectAvailableCDs(void)
if (add_it)
{
char **tmp = realloc(retval, sizeof (char *) * cd_count + 1);
char **tmp = realloc(retval, sizeof (char *) * (cd_count + 1));
if (tmp)
{
retval = tmp;
retval[cd_count-1] = (char *)
malloc(strlen(mntbufp[ ii ].f_mntonname) + 1);
if (retval[cd_count-1])
retval[cd_count - 1] = (char *)
malloc(strlen(mntbufp[ii].f_mntonname) + 1);
if (retval[cd_count - 1])
{
strcpy(retval[cd_count-1], mntbufp[ ii ].f_mntonname);
strcpy(retval[cd_count - 1], mntbufp[ii].f_mntonname);
cd_count++;
} /* if */
} /* if */
@ -137,14 +137,14 @@ char **__PHYSFS_platformDetectAvailableCDs(void)
if (add_it)
{
char **tmp = realloc(retval, sizeof (char *) * cd_count + 1);
char **tmp = realloc(retval, sizeof (char *) * (cd_count + 1));
if (tmp)
{
retval = tmp;
retval[cd_count-1] = (char *) malloc(strlen(ent->mnt_dir) + 1);
if (retval[cd_count-1])
if (retval[cd_count - 1])
{
strcpy(retval[cd_count-1], ent->mnt_dir);
strcpy(retval[cd_count - 1], ent->mnt_dir);
cd_count++;
} /* if */
} /* if */