From 7001121a3f440177f5b5d1857420a34808e7be35 Mon Sep 17 00:00:00 2001 From: Thomas Schmitt Date: Thu, 12 Jul 2012 18:16:38 +0200 Subject: [PATCH] New flag bit with iso_node_set_attrs() to protect namespace "isofs" --- libisofs/hfsplus.c | 2 +- libisofs/libisofs.h | 4 ++++ libisofs/node.c | 11 ++++++++--- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/libisofs/hfsplus.c b/libisofs/hfsplus.c index f933dfc..9e63241 100644 --- a/libisofs/hfsplus.c +++ b/libisofs/hfsplus.c @@ -11,7 +11,7 @@ */ -/* Some extra debugging messages for Vladimir Serbinko +/* Some extra debugging messages for Vladimir Serbinenko #define Libisofs_hfsplus_verbose_debuG yes */ diff --git a/libisofs/libisofs.h b/libisofs/libisofs.h index 8ded7c9..97593b5 100644 --- a/libisofs/libisofs.h +++ b/libisofs/libisofs.h @@ -6076,6 +6076,10 @@ int iso_node_lookup_attr(IsoNode *node, char *name, * I.e. those with a non-empty name which does not begin by "user." * (The empty name is always allowed and governed by bit0.) This * deletes all previously existing attributes if not bit1 is set. + * bit4= Do not affect attributes from namespace "isofs". + * To be combined with bit3 for copying attributes from local + * filesystem to ISO image. + * @since 1.2.4 * @return * 1 = ok * < 0 = error diff --git a/libisofs/node.c b/libisofs/node.c index ae04974..9956a06 100644 --- a/libisofs/node.c +++ b/libisofs/node.c @@ -1727,6 +1727,7 @@ int attr_enlarge_list(char ***names, size_t **value_lengths, char ***values, bit2= delete the given names rather than overwrite their content bit4= do not overwrite value of empty name + bit5= do not overwrite isofs attributes bit15= release memory and return 1 */ static @@ -1775,6 +1776,8 @@ int iso_node_merge_xattr(IsoNode *node, size_t num_attrs, char **names, continue; if (names[i][0] == 0 && (flag & 16)) continue; + if ((flag & 32) && strncmp(names[i], "isofs.", 6) == 0) + continue; for (j = 0; j < *m_num_attrs; j++) { if ((*m_names)[j] == NULL) continue; @@ -1820,6 +1823,8 @@ int iso_node_merge_xattr(IsoNode *node, size_t num_attrs, char **names, continue; if (names[i][0] == 0 && (flag & 16)) continue; + if ((flag & 32) && strncmp(names[i], "isofs.", 6) == 0) + continue; for (j = 0; j < *m_num_attrs; j++) { if ((*m_names)[j] == NULL) continue; @@ -1870,13 +1875,13 @@ int iso_node_set_attrs(IsoNode *node, size_t num_attrs, char **names, for (i = 0; i < num_attrs; i++) if (strncmp(names[i], "user.", 5) != 0 && names[i][0] != 0) return ISO_AAIP_NON_USER_NAME; - - if ((flag & (2 | 4)) || !(flag & 8)) { + if ((flag & (2 | 4 | 16)) || !(flag & 8)) { /* Merge old and new lists */ ret = iso_node_merge_xattr( node, num_attrs, names, value_lengths, values, &m_num, &m_names, &m_value_lengths, &m_values, - (flag & 4) | (!(flag & 2)) | ((!(flag & 1)) << 4)); + (flag & 4) | (!(flag & 2)) | ((!(flag & 1)) << 4) | + ((flag & 16) << 1)); if (ret < 0) goto ex; num_attrs = m_num;