Fix crash with Linux supermount fstab entries (thanks Erno!)
authorSam Lantinga <slouken@libsdl.org>
Wed, 05 Dec 2001 23:49:09 +0000
changeset 247b0f09f86378d
parent 246 7c09c9e3b0c7
child 248 8e47ebb7bced
Fix crash with Linux supermount fstab entries (thanks Erno!)
src/cdrom/linux/SDL_syscdrom.c
     1.1 --- a/src/cdrom/linux/SDL_syscdrom.c	Tue Nov 27 01:26:57 2001 +0000
     1.2 +++ b/src/cdrom/linux/SDL_syscdrom.c	Wed Dec 05 23:49:09 2001 +0000
     1.3 @@ -203,18 +203,24 @@
     1.4  			if ( strcmp(mnt_type, MNTTYPE_SUPER) == 0 ) {
     1.5  				tmp = strstr(mntent->mnt_opts, "fs=");
     1.6  				if ( tmp ) {
     1.7 -					strcpy(mnt_type, tmp+strlen("fs="));
     1.8 -					tmp = strchr(mnt_type, ',');
     1.9 -					if ( tmp ) {
    1.10 -						*tmp = '\0';
    1.11 +					free(mnt_type);
    1.12 +					mnt_type = strdup(tmp + strlen("fs="));
    1.13 +					if ( mnt_type ) {
    1.14 +						tmp = strchr(mnt_type, ',');
    1.15 +						if ( tmp ) {
    1.16 +							*tmp = '\0';
    1.17 +						}
    1.18  					}
    1.19  				}
    1.20  				tmp = strstr(mntent->mnt_opts, "dev=");
    1.21  				if ( tmp ) {
    1.22 -					strcpy(mnt_dev, tmp+strlen("dev="));
    1.23 -					tmp = strchr(mnt_dev, ',');
    1.24 -					if ( tmp ) {
    1.25 -						*tmp = '\0';
    1.26 +					free(mnt_dev);
    1.27 +					mnt_dev = strdup(tmp + strlen("dev="));
    1.28 +					if ( mnt_dev ) {
    1.29 +						tmp = strchr(mnt_dev, ',');
    1.30 +						if ( tmp ) {
    1.31 +							*tmp = '\0';
    1.32 +						}
    1.33  					}
    1.34  				}
    1.35  			}