Changes by: antona
Update of /cvsroot/linux-ntfs/linux-ntfs/libntfs
In directory usw-pr-cvs1:/tmp/cvs-serv10948/libntfs
Modified Files:
attrib.c
Log Message:
A little (potential) fix or better call it bug prevention and some cleanup.
Index: attrib.c
===================================================================
RCS file: /cvsroot/linux-ntfs/linux-ntfs/libntfs/attrib.c,v
retrieving revision 1.54
retrieving revision 1.55
diff -U2 -r1.54 -r1.55
--- attrib.c 8 Jul 2002 23:27:15 -0000 1.54
+++ attrib.c 9 Jul 2002 00:02:31 -0000 1.55
@@ -402,4 +402,5 @@
} else {
na->name = AT_NONAME;
+ na->name_len = 0;
}
}
@@ -526,4 +527,5 @@
/**
* ntfs_attr_close - free an ntfs attribute structure
+
* @na: ntfs attribute structure to free
*
@@ -2407,4 +2409,8 @@
* to interoperate cleanly with ntfs_find_external_attr().
*
+ * If @name is AT_NONAME search for an unnamed attribute. If @name is present
+ * but not AT_NONAME search for a named attribute matching @name. Otherwise,
+ * match both named and unnamed attributes.
+ *
* If @ic is IGNORE_CASE, the @name comparisson is not case sensitive and
* @ctx->ntfs_ino must be set to the ntfs inode to which the mft record
@@ -2488,7 +2494,5 @@
* Otherwise, match any attribute.
*/
- if (!name) {
- // do nothing
- } else if (name == AT_NONAME) {
+ if (name == AT_NONAME) {
/* The search failed if the found attribute is named. */
if (a->name_length) {
@@ -2496,5 +2500,5 @@
return -1;
}
- } else if (!ntfs_are_names_equal(name, name_len,
+ } else if (name && !ntfs_are_names_equal(name, name_len,
(uchar_t*)((char*)a + le16_to_cpu(a->name_offset)),
a->name_length, ic, upcase, upcase_len)) {
@@ -2600,4 +2604,8 @@
* safer to return error instead of success in this case.
*
+ * If @name is AT_NONAME search for an unnamed attribute. If @name is present
+ * but not AT_NONAME search for a named attribute matching @name. Otherwise,
+ * match both named and unnamed attributes.
+ *
* On first search @ctx->ntfs_ino must be the inode of the base mft record and
* @ctx must have been obtained from a call to ntfs_get_attr_search_ctx().
@@ -2692,9 +2700,4 @@
continue;
}
- /*
- * If @name is AT_NONAME we want an unnamed attribute.
- * If @name is present, compare the two names.
- * Otherwise, match any attribute.
- */
al_name_len = al_entry->name_length;
al_name = (uchar_t*)((char*)al_entry + al_entry->name_offset);
@@ -2705,11 +2708,15 @@
if (!type)
goto is_enumeration;
- if (!name) {
- // do nothing
- } else if (name == AT_NONAME) {
+ /*
+ * If @name is AT_NONAME we want an unnamed attribute.
+ * If @name is present, compare the two names.
+ * Otherwise, match any attribute.
+ */
+ if (name == AT_NONAME) {
if (al_name_len)
goto not_found;
- } else if (!ntfs_are_names_equal(al_name, al_name_len, name,
- name_len, ic, vol->upcase, vol->upcase_len)) {
+ } else if (name && !ntfs_are_names_equal(al_name, al_name_len,
+ name, name_len, ic, vol->upcase,
+ vol->upcase_len)) {
register int rc;
@@ -2917,4 +2924,8 @@
* It should never ne needed to do this, but we implement the functionality
* because it allows for simpler code inside ntfs_find_external_attr().
+ *
+ * If @name is AT_NONAME search for an unnamed attribute. If @name is present
+ * but not AT_NONAME search for a named attribute matching @name. Otherwise,
+ * match both named and unnamed attributes.
*
* After finishing with the attribute/mft record you need to call
|