[Yaffs] bug in yaffsfs_FindDevice?

Top Page
Attachments:
Message as email
+ (text/plain)
Delete this message
Reply to this message
Author: Trent Lillehaugen
Date:  
To: yaffs@lists.aleph1.co.uk
Subject: [Yaffs] bug in yaffsfs_FindDevice?
I noticed the following problem with yaffsfs_FindDevice.

Let's say I have two yaffs partitions: "/" and "/foo". If I call, yaffs_mkdir("/foobar", 0), yaffsfs_FindDevice will match the path with the "/foo" partition. I would expect it to match "/" instead. It will also match "/fo/o/bar" with "/foo", again I think it should match with "/".

The following patch seems to fix the problems for me:

Index: yaffsfs.c
===================================================================
--- yaffsfs.c   (revision 90876)
+++ yaffsfs.c   (working copy)
@@ -323,16 +323,15 @@
                thisMatchLength = 0;
                matching = 1;


+                /* Skip over any /s */
+                while(yaffsfs_IsPathDivider(*p))
+                   p++;


+                /* Skip over any /s */
+                while(yaffsfs_IsPathDivider(*leftOver))
+                   leftOver++;
+
                while(matching && *p && *leftOver){
-                       /* Skip over any /s */
-                       while(yaffsfs_IsPathDivider(*p))
-                             p++;
-
-                       /* Skip over any /s */
-                       while(yaffsfs_IsPathDivider(*leftOver))
-                             leftOver++;
-
                        /* Now match the text part */
                        while(matching &&
                              *p && !yaffsfs_IsPathDivider(*p) &&
@@ -344,9 +343,25 @@
                                } else {
                                        matching = 0;
                                }
-                       }
+                       }
+
+                        if (
+                            (*p && !yaffsfs_IsPathDivider(*p)) ||
+                            (*leftOver && !yaffsfs_IsPathDivider(*leftOver))
+                            )
+                        {
+                            matching = 0;
+                        } else {
+                            /* Skip over any /s */
+                            while(yaffsfs_IsPathDivider(*p))
+                                p++;
+
+                            /* Skip over any /s */
+                            while(yaffsfs_IsPathDivider(*leftOver))
+                                leftOver++;
+                        }
                }
-
+
                /* Skip over any /s in leftOver */
                while(yaffsfs_IsPathDivider(*leftOver))
                      leftOver++;


Trent Lillehaugen

________________________________

This e-mail is the property of RED Digital Cinema Camera Company. It is intended only for the person or entity to which it is addressed and may contain information that is privileged, confidential, or otherwise protected from disclosure. Distribution or copying of this e-mail, or the information contained herein, to anyone other than the intended recipient is prohibited.