From 0d009db3746a5e781031d4ccc16a0356d656d21b Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Wed, 5 Dec 2001 23:49:09 +0000 Subject: [PATCH] Fix crash with Linux supermount fstab entries (thanks Erno!) --- src/cdrom/linux/SDL_syscdrom.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/cdrom/linux/SDL_syscdrom.c b/src/cdrom/linux/SDL_syscdrom.c index d7806fb19..51b3a4c39 100644 --- a/src/cdrom/linux/SDL_syscdrom.c +++ b/src/cdrom/linux/SDL_syscdrom.c @@ -203,18 +203,24 @@ static void CheckMounts(const char *mtab) if ( strcmp(mnt_type, MNTTYPE_SUPER) == 0 ) { tmp = strstr(mntent->mnt_opts, "fs="); if ( tmp ) { - strcpy(mnt_type, tmp+strlen("fs=")); - tmp = strchr(mnt_type, ','); - if ( tmp ) { - *tmp = '\0'; + free(mnt_type); + mnt_type = strdup(tmp + strlen("fs=")); + if ( mnt_type ) { + tmp = strchr(mnt_type, ','); + if ( tmp ) { + *tmp = '\0'; + } } } tmp = strstr(mntent->mnt_opts, "dev="); if ( tmp ) { - strcpy(mnt_dev, tmp+strlen("dev=")); - tmp = strchr(mnt_dev, ','); - if ( tmp ) { - *tmp = '\0'; + free(mnt_dev); + mnt_dev = strdup(tmp + strlen("dev=")); + if ( mnt_dev ) { + tmp = strchr(mnt_dev, ','); + if ( tmp ) { + *tmp = '\0'; + } } } }