New flag bit with iso_node_set_attrs() to protect namespace "isofs"

This commit is contained in:
Thomas Schmitt 2012-07-12 18:16:38 +02:00
parent 942ec97c7b
commit 7001121a3f
3 changed files with 13 additions and 4 deletions

View File

@ -11,7 +11,7 @@
*/ */
/* Some extra debugging messages for Vladimir Serbinko /* Some extra debugging messages for Vladimir Serbinenko
#define Libisofs_hfsplus_verbose_debuG yes #define Libisofs_hfsplus_verbose_debuG yes
*/ */

View File

@ -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." * 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 * (The empty name is always allowed and governed by bit0.) This
* deletes all previously existing attributes if not bit1 is set. * 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 * @return
* 1 = ok * 1 = ok
* < 0 = error * < 0 = error

View File

@ -1727,6 +1727,7 @@ int attr_enlarge_list(char ***names, size_t **value_lengths, char ***values,
bit2= delete the given names rather than overwrite bit2= delete the given names rather than overwrite
their content their content
bit4= do not overwrite value of empty name bit4= do not overwrite value of empty name
bit5= do not overwrite isofs attributes
bit15= release memory and return 1 bit15= release memory and return 1
*/ */
static static
@ -1775,6 +1776,8 @@ int iso_node_merge_xattr(IsoNode *node, size_t num_attrs, char **names,
continue; continue;
if (names[i][0] == 0 && (flag & 16)) if (names[i][0] == 0 && (flag & 16))
continue; continue;
if ((flag & 32) && strncmp(names[i], "isofs.", 6) == 0)
continue;
for (j = 0; j < *m_num_attrs; j++) { for (j = 0; j < *m_num_attrs; j++) {
if ((*m_names)[j] == NULL) if ((*m_names)[j] == NULL)
continue; continue;
@ -1820,6 +1823,8 @@ int iso_node_merge_xattr(IsoNode *node, size_t num_attrs, char **names,
continue; continue;
if (names[i][0] == 0 && (flag & 16)) if (names[i][0] == 0 && (flag & 16))
continue; continue;
if ((flag & 32) && strncmp(names[i], "isofs.", 6) == 0)
continue;
for (j = 0; j < *m_num_attrs; j++) { for (j = 0; j < *m_num_attrs; j++) {
if ((*m_names)[j] == NULL) if ((*m_names)[j] == NULL)
continue; 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++) for (i = 0; i < num_attrs; i++)
if (strncmp(names[i], "user.", 5) != 0 && names[i][0] != 0) if (strncmp(names[i], "user.", 5) != 0 && names[i][0] != 0)
return ISO_AAIP_NON_USER_NAME; return ISO_AAIP_NON_USER_NAME;
if ((flag & (2 | 4 | 16)) || !(flag & 8)) {
if ((flag & (2 | 4)) || !(flag & 8)) {
/* Merge old and new lists */ /* Merge old and new lists */
ret = iso_node_merge_xattr( ret = iso_node_merge_xattr(
node, num_attrs, names, value_lengths, values, node, num_attrs, names, value_lengths, values,
&m_num, &m_names, &m_value_lengths, &m_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) if (ret < 0)
goto ex; goto ex;
num_attrs = m_num; num_attrs = m_num;