]> git.tuebingen.mpg.de Git - paraslash.git/blobdiff - attribute.c
Avoid member access within misaligned address for ancillary data buffer.
[paraslash.git] / attribute.c
index 96b54c99080deb62b0b593e62d6470306c601886..65f08aef4c062c79b6b204b628fe0bbf0c98e8bb 100644 (file)
@@ -162,7 +162,7 @@ static void com_lsatt_callback(int fd, const struct osl_object *query)
        };
        struct pattern_match_data pmd = {
                .table = attribute_table,
-               .loop_col_num = ATTCOL_BITNUM,
+               .loop_col_num = ATTCOL_NAME,
                .match_col_num = ATTCOL_NAME,
                .patterns = {.data = (char *)query->data + sizeof(laad.flags),
                        .size = query->size - sizeof(laad.flags)},
@@ -171,7 +171,7 @@ static void com_lsatt_callback(int fd, const struct osl_object *query)
                .action = print_attribute
        };
        if (laad.flags & LSATT_FLAG_SORT_BY_ID)
-               pmd.loop_col_num = ATTCOL_NAME;
+               pmd.loop_col_num = ATTCOL_BITNUM;
        if (laad.flags & LSATT_FLAG_REVERSE)
                pmd.pm_flags |= PM_REVERSE_LOOP;
        for_each_matching_row(&pmd);
@@ -222,7 +222,7 @@ int com_lsatt(struct command_context *cc)
 static void com_setatt_callback(__a_unused int fd, const struct osl_object *query)
 {
        char *p;
-       uint64_t add_mask = 0, del_mask = 0;
+       uint64_t add_mask = 0, del_mask = 0, one = 1;
        int ret;
        size_t len;
        struct osl_object obj;
@@ -249,9 +249,9 @@ static void com_setatt_callback(__a_unused int fd, const struct osl_object *quer
                if (ret < 0)
                        goto out;
                if (c == '+')
-                       add_mask |= (1UL << *(unsigned char *)obj.data);
+                       add_mask |= (one << *(unsigned char *)obj.data);
                else
-                       del_mask |= (1UL << *(unsigned char *)obj.data);
+                       del_mask |= (one << *(unsigned char *)obj.data);
        }
        ret = -E_ATTR_SYNTAX;
        if (!add_mask && !del_mask)