[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

mkfs.jffs bug fix (for Ultra-Sparc)



Hej,

i found a bug in mkfs.jffs v.1.16 (jffs_print_trace() function) which
caused mkfs.jffs to segfault on UltraSparcs if verbose was set > 0

here is the original code (begining at line 98 of mkfs.jffs_1.16.c):

  while (path[pos] && (path[pos] != '/'))
  {
    pos--;
  }

the first stop condition assumes that the memory in front of the 'path'
char string is '\0', which seems to be luckily the case on Linux/i86,
but not on Linux/UltraSparc.

here is how i fixed it (with the modifications on the following lines):

  while (pos && (path[pos] != '/'))
  {
    pos--;
  }
  if(pos)
    pos++;      /* increment pos if path[pos] is '/' */
  for (; path[pos] && (path[pos] != '/'); pos++)
  {
    out[out_pos++] = path[pos];
  }


the diff -u file:

--- mkfs.jffs.c.orig    Tue Apr 16 19:05:59 2002
+++ mkfs.jffs.c Tue Apr 16 19:37:06 2002
@@ -117,11 +117,13 @@
   {
     pos--;
   }
-  while (path[pos] && (path[pos] != '/'))
+  while (pos && (path[pos] != '/'))
   {
     pos--;
   }
-  for (pos++; path[pos] && (path[pos] != '/'); pos++)
+  if(pos)
+    pos++;     /* increment pos if path[pos] is '/' */
+  for (; path[pos] && (path[pos] != '/'); pos++)
   {
     out[out_pos++] = path[pos];
   }


hope that helps (but etrax100boot still doesn't run on UltraSparcs :-(

/Martin

To unsubscribe from this list: send the line "unsubscribe jffs-dev" in
the body of a message to majordomo@xxxxxxx.com