Okay, this isn’t really a fix so much as a cleanup, but seeing comments
like “/* Caution: potential buffer overflow! */” drives me nuts, so I
fixed it.
Attached is a patch to clean up such a warning in the Linux SDL CD-ROM code.
To apply:
cd /where/i/installed/the/cvs/version/of/SDL12
patch -p1 < SDL-linux-cdrom-overflow-RYAN1.diff
–ryan.
-------------- next part --------------
— SDL12/src/cdrom/linux/SDL_syscdrom.c-virgin Mon Aug 6 23:03:16 2001
+++ SDL12/src/cdrom/linux/SDL_syscdrom.c Mon Aug 6 23:04:18 2001
@@ -181,10 +181,21 @@
mntfp = setmntent(mtab, "r");
if ( mntfp != NULL ) {
-
char *tmp, mnt_type[32], mnt_dev[1024];
-
char *tmp;
-
char *mnt_type;
-
char *mnt_dev; while ( (mntent=getmntent(mntfp)) != NULL ) {
-
/* Warning, possible buffer overflow.. */
-
mnt_type = malloc(strlen(mntent->mnt_type) + 1);
-
if (mnt_type == NULL)
-
continue; /* maybe you'll get lucky next time. */+
-
mnt_dev = malloc(strlen(mntent->mnt_fsname) + 1);
-
if (mnt_dev == NULL) {
-
free(mnt_type);
-
continue;
-
}
-
strcpy(mnt_type, mntent->mnt_type); strcpy(mnt_dev, mntent->mnt_fsname);
@@ -216,6 +227,8 @@
AddDrive(mnt_dev, &stbuf);
}
}
-
free(mnt_dev);
-
}free(mnt_type); } endmntent(mntfp);