Skip to contentSkip to conversation

2.5.4-dj3 fix some uses of strsep

PATCH New René Scharfe 1 participant 1 message Feb 20, 2002

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 2.5.4-dj3 fix some uses of strsep

Dave,

patch below fixes four cases where a s/strtok(/strsep(\&/ is not sufficient to properly eliminate strtok. The problem arrises because strsep modifies the pointer it is given while strtok did not.

The atari file doesn't compile without this patch, because a char array is mistreated as char pointer. The rest are cases where the destroyed char pointer is used afterwards.

There may be more errors of that kind, I didn't check (yet). Patch is untested but should make things "righter". ;)

René

arch/alpha/kernel/setup.c +2 -1
diff -ur linux-2.5.4-dj3/arch/alpha/kernel/setup.c linux/arch/alpha/kernel/setup.c
@@ -472,6 +472,7 @@
 	struct percpu_struct *cpu;
 	char *type_name, *var_name, *p;
 	void *kernel_end = _end; /* end of kernel */
+	char *args = command_line;
 
 	hwrpb = (struct hwrpb_struct*) __va(INIT_HWRPB->phys_addr);
 	boot_cpuid = hard_smp_processor_id();
@@ -509,7 +510,7 @@
 	/* 
 	 * Process command-line arguments.
 	 */
-	while ((p = strsep(&command_line, " \t")) != NULL) {
+	while ((p = strsep(&args, " \t")) != NULL) {
 		if (!*p) continue;
 		if (strncmp(p, "alpha_mv=", 9) == 0) {
 			vec = get_sysvec_byname(p+9);
arch/m68k/atari/config.c +2 -1
diff -ur linux-2.5.4-dj3/arch/m68k/atari/config.c linux/arch/m68k/atari/config.c
@@ -205,6 +205,7 @@
     char switches[len+1];
     char *p;
     int ovsc_shift;
+    char *args = switches;
 
     /* copy string to local array, strsep works destructively... */
     strncpy( switches, str, len );
@@ -212,7 +213,7 @@
     atari_switches = 0;
 
     /* parse the options */
-    while ((p = strsep(&switches, ",")) != NULL) {
+    while ((p = strsep(&args, ",")) != NULL) {
 	if (!*p) continue;
 	ovsc_shift = 0;
 	if (strncmp( p, "ov_", 3 ) == 0) {
fs/fat/inode.c +2 -1
diff -ur linux-2.5.4-dj3/fs/fat/inode.c linux/fs/fat/inode.c
@@ -203,6 +203,7 @@
 	char *this_char,*value,save,*savep;
 	char *p;
 	int ret = 1, len;
+	char *args = options;
 
 	opts->name_check = 'n';
 	opts->conversion = 'b';
@@ -221,7 +222,7 @@
 		goto out;
 	save = 0;
 	savep = NULL;
-	while ((this_char = strsep(&options,",")) != NULL) {
+	while ((this_char = strsep(&args,",")) != NULL) {
 		if ((value = strchr(this_char,'=')) != NULL) {
 			save = *value;
 			savep = value;
fs/vfat/namei.c +2 -1
diff -ur linux-2.5.4-dj3/fs/vfat/namei.c linux/fs/vfat/namei.c
@@ -99,6 +99,7 @@
 {
 	char *this_char,*value,save,*savep;
 	int ret, val;
+	char *args = options;
 
 	opts->unicode_xlate = opts->posixfs = 0;
 	opts->numtail = 1;
@@ -115,7 +116,7 @@
 	save = 0;
 	savep = NULL;
 	ret = 1;
-	while ((this_char = strsep(&options,",")) != NULL) {
+	while ((this_char = strsep(&args,",")) != NULL) {
 		if ((value = strchr(this_char,'=')) != NULL) {
 			save = *value;
 			savep = value;