Fixed several endianness errors
							parent
							
								
									62407b6b1e
								
							
						
					
					
						commit
						6886650afc
					
				| 
						 | 
					@ -177,6 +177,12 @@ struct SECURITY_API {
 | 
				
			||||||
	struct SECURITY_CACHE *seccache;
 | 
						struct SECURITY_CACHE *seccache;
 | 
				
			||||||
} ;
 | 
					} ;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/*
 | 
				
			||||||
 | 
					 *  The following constants are used in interfacing external programs.
 | 
				
			||||||
 | 
					 *  They are not to be stored on disk and must be defined in their
 | 
				
			||||||
 | 
					 *  native cpu representation.
 | 
				
			||||||
 | 
					 *  When disk representation (le) is needed, use SE_DACL_PRESENT, etc.
 | 
				
			||||||
 | 
					 */
 | 
				
			||||||
enum {	OWNER_SECURITY_INFORMATION = 1,
 | 
					enum {	OWNER_SECURITY_INFORMATION = 1,
 | 
				
			||||||
	GROUP_SECURITY_INFORMATION = 2,
 | 
						GROUP_SECURITY_INFORMATION = 2,
 | 
				
			||||||
	DACL_SECURITY_INFORMATION = 4,
 | 
						DACL_SECURITY_INFORMATION = 4,
 | 
				
			||||||
| 
						 | 
					@ -194,5 +200,4 @@ struct SECURITY_API *ntfs_initialize_file_security(const char *device,
 | 
				
			||||||
                                int flags);
 | 
					                                int flags);
 | 
				
			||||||
BOOL ntfs_leave_file_security(struct SECURITY_API *scx);
 | 
					BOOL ntfs_leave_file_security(struct SECURITY_API *scx);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					 | 
				
			||||||
#endif /* defined _NTFS_SECURITY_H */
 | 
					#endif /* defined _NTFS_SECURITY_H */
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -3909,7 +3909,8 @@ static BOOL feedsecurityattr(const char *attr, u32 selection,
 | 
				
			||||||
	size = 0;
 | 
						size = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		/* locate DACL if requested and available */
 | 
							/* locate DACL if requested and available */
 | 
				
			||||||
	if (selection & phead->control & DACL_SECURITY_INFORMATION) {
 | 
						if (le16_to_cpu(phead->control)
 | 
				
			||||||
 | 
								 & (selection & DACL_SECURITY_INFORMATION)) {
 | 
				
			||||||
		offdacl = le32_to_cpu(phead->dacl);
 | 
							offdacl = le32_to_cpu(phead->dacl);
 | 
				
			||||||
		pdacl = (const ACL*)&attr[offdacl];
 | 
							pdacl = (const ACL*)&attr[offdacl];
 | 
				
			||||||
		daclsz = le16_to_cpu(pdacl->size);
 | 
							daclsz = le16_to_cpu(pdacl->size);
 | 
				
			||||||
| 
						 | 
					@ -3943,7 +3944,8 @@ static BOOL feedsecurityattr(const char *attr, u32 selection,
 | 
				
			||||||
		offgroup = gsidsz = 0;
 | 
							offgroup = gsidsz = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		/* locate SACL if requested and available */
 | 
							/* locate SACL if requested and available */
 | 
				
			||||||
	if (selection & phead->control & SACL_SECURITY_INFORMATION) {
 | 
						if (le16_to_cpu(phead->control)
 | 
				
			||||||
 | 
							 & (selection & SACL_SECURITY_INFORMATION)) {
 | 
				
			||||||
			/* find end of SACL */
 | 
								/* find end of SACL */
 | 
				
			||||||
		offsacl = le32_to_cpu(phead->sacl);
 | 
							offsacl = le32_to_cpu(phead->sacl);
 | 
				
			||||||
		psacl = (const ACL*)&attr[offsacl];
 | 
							psacl = (const ACL*)&attr[offsacl];
 | 
				
			||||||
| 
						 | 
					@ -3966,40 +3968,40 @@ static BOOL feedsecurityattr(const char *attr, u32 selection,
 | 
				
			||||||
		/* copy header and feed new flags */
 | 
							/* copy header and feed new flags */
 | 
				
			||||||
		memcpy(buf,attr,sizeof(SECURITY_DESCRIPTOR_RELATIVE));
 | 
							memcpy(buf,attr,sizeof(SECURITY_DESCRIPTOR_RELATIVE));
 | 
				
			||||||
		pnhead = (SECURITY_DESCRIPTOR_RELATIVE*)buf;
 | 
							pnhead = (SECURITY_DESCRIPTOR_RELATIVE*)buf;
 | 
				
			||||||
		pnhead->control = avail;
 | 
							pnhead->control = cpu_to_le16(avail);
 | 
				
			||||||
		pos = sizeof(SECURITY_DESCRIPTOR_RELATIVE);
 | 
							pos = sizeof(SECURITY_DESCRIPTOR_RELATIVE);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		/* copy DACL if requested */
 | 
							/* copy DACL if requested */
 | 
				
			||||||
		if (selection & DACL_SECURITY_INFORMATION) {
 | 
							if (selection & DACL_SECURITY_INFORMATION) {
 | 
				
			||||||
			pnhead->dacl = pos;
 | 
								pnhead->dacl = cpu_to_le32(pos);
 | 
				
			||||||
			memcpy(&buf[pos],&attr[offdacl],daclsz);
 | 
								memcpy(&buf[pos],&attr[offdacl],daclsz);
 | 
				
			||||||
			pos += daclsz;
 | 
								pos += daclsz;
 | 
				
			||||||
		} else
 | 
							} else
 | 
				
			||||||
			pnhead->dacl = 0;
 | 
								pnhead->dacl = cpu_to_le32(0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		/* copy SACL if requested */
 | 
							/* copy SACL if requested */
 | 
				
			||||||
		if (selection & SACL_SECURITY_INFORMATION) {
 | 
							if (selection & SACL_SECURITY_INFORMATION) {
 | 
				
			||||||
			pnhead->sacl = pos;
 | 
								pnhead->sacl = cpu_to_le32(pos);
 | 
				
			||||||
			memcpy(&buf[pos],&attr[offsacl],saclsz);
 | 
								memcpy(&buf[pos],&attr[offsacl],saclsz);
 | 
				
			||||||
			pos += saclsz;
 | 
								pos += saclsz;
 | 
				
			||||||
		} else
 | 
							} else
 | 
				
			||||||
			pnhead->sacl = 0;
 | 
								pnhead->sacl = cpu_to_le32(0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		/* copy owner if requested */
 | 
							/* copy owner if requested */
 | 
				
			||||||
		if (selection & OWNER_SECURITY_INFORMATION) {
 | 
							if (selection & OWNER_SECURITY_INFORMATION) {
 | 
				
			||||||
			pnhead->owner = pos;
 | 
								pnhead->owner = cpu_to_le32(pos);
 | 
				
			||||||
			memcpy(&buf[pos],&attr[offowner],usidsz);
 | 
								memcpy(&buf[pos],&attr[offowner],usidsz);
 | 
				
			||||||
			pos += usidsz;
 | 
								pos += usidsz;
 | 
				
			||||||
		} else
 | 
							} else
 | 
				
			||||||
			pnhead->owner = 0;
 | 
								pnhead->owner = cpu_to_le32(0);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		/* copy group if requested */
 | 
							/* copy group if requested */
 | 
				
			||||||
		if (selection & GROUP_SECURITY_INFORMATION) {
 | 
							if (selection & GROUP_SECURITY_INFORMATION) {
 | 
				
			||||||
			pnhead->group = pos;
 | 
								pnhead->group = cpu_to_le32(pos);
 | 
				
			||||||
			memcpy(&buf[pos],&attr[offgroup],gsidsz);
 | 
								memcpy(&buf[pos],&attr[offgroup],gsidsz);
 | 
				
			||||||
			pos += gsidsz;
 | 
								pos += gsidsz;
 | 
				
			||||||
		} else
 | 
							} else
 | 
				
			||||||
			pnhead->group = 0;
 | 
								pnhead->group = cpu_to_le32(0);
 | 
				
			||||||
		if (pos != size)
 | 
							if (pos != size)
 | 
				
			||||||
			ntfs_log_error("Error in security descriptor size\n");
 | 
								ntfs_log_error("Error in security descriptor size\n");
 | 
				
			||||||
		*psize = size;
 | 
							*psize = size;
 | 
				
			||||||
| 
						 | 
					@ -4047,7 +4049,7 @@ static BOOL mergesecurityattr(ntfs_volume *vol, const char *oldattr,
 | 
				
			||||||
	if (target) {
 | 
						if (target) {
 | 
				
			||||||
		targhead = (SECURITY_DESCRIPTOR_RELATIVE*)target;
 | 
							targhead = (SECURITY_DESCRIPTOR_RELATIVE*)target;
 | 
				
			||||||
		pos = sizeof(SECURITY_DESCRIPTOR_RELATIVE);
 | 
							pos = sizeof(SECURITY_DESCRIPTOR_RELATIVE);
 | 
				
			||||||
		present = oldhead->control;
 | 
							present = le16_to_cpu(oldhead->control);
 | 
				
			||||||
		if (oldhead->owner)
 | 
							if (oldhead->owner)
 | 
				
			||||||
			present |= OWNER_SECURITY_INFORMATION;
 | 
								present |= OWNER_SECURITY_INFORMATION;
 | 
				
			||||||
		if (oldhead->group)
 | 
							if (oldhead->group)
 | 
				
			||||||
| 
						 | 
					@ -4066,10 +4068,10 @@ static BOOL mergesecurityattr(ntfs_volume *vol, const char *oldattr,
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			size = le16_to_cpu(pdacl->size);
 | 
								size = le16_to_cpu(pdacl->size);
 | 
				
			||||||
			memcpy(&target[pos], pdacl, size);
 | 
								memcpy(&target[pos], pdacl, size);
 | 
				
			||||||
			targhead->dacl = pos;
 | 
								targhead->dacl = cpu_to_le32(pos);
 | 
				
			||||||
			pos += size;
 | 
								pos += size;
 | 
				
			||||||
		} else
 | 
							} else
 | 
				
			||||||
			targhead->dacl = 0;
 | 
								targhead->dacl = cpu_to_le32(0);
 | 
				
			||||||
			/*
 | 
								/*
 | 
				
			||||||
			 * copy new SACL if selected
 | 
								 * copy new SACL if selected
 | 
				
			||||||
			 * or keep old SACL if any
 | 
								 * or keep old SACL if any
 | 
				
			||||||
| 
						 | 
					@ -4084,10 +4086,10 @@ static BOOL mergesecurityattr(ntfs_volume *vol, const char *oldattr,
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			size = le16_to_cpu(psacl->size);
 | 
								size = le16_to_cpu(psacl->size);
 | 
				
			||||||
			memcpy(&target[pos], psacl, size);
 | 
								memcpy(&target[pos], psacl, size);
 | 
				
			||||||
			targhead->sacl = pos;
 | 
								targhead->sacl = cpu_to_le32(pos);
 | 
				
			||||||
			pos += size;
 | 
								pos += size;
 | 
				
			||||||
		} else
 | 
							} else
 | 
				
			||||||
			targhead->sacl = 0;
 | 
								targhead->sacl = cpu_to_le32(0);
 | 
				
			||||||
			/*
 | 
								/*
 | 
				
			||||||
			 * copy new OWNER if selected
 | 
								 * copy new OWNER if selected
 | 
				
			||||||
			 * or keep old OWNER if any
 | 
								 * or keep old OWNER if any
 | 
				
			||||||
| 
						 | 
					@ -4102,10 +4104,10 @@ static BOOL mergesecurityattr(ntfs_volume *vol, const char *oldattr,
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			size = sid_size(powner);
 | 
								size = sid_size(powner);
 | 
				
			||||||
			memcpy(&target[pos], powner, size);
 | 
								memcpy(&target[pos], powner, size);
 | 
				
			||||||
			targhead->owner = pos;
 | 
								targhead->owner = cpu_to_le32(pos);
 | 
				
			||||||
			pos += size;
 | 
								pos += size;
 | 
				
			||||||
		} else
 | 
							} else
 | 
				
			||||||
			targhead->owner = 0;
 | 
								targhead->owner = cpu_to_le32(0);
 | 
				
			||||||
			/*
 | 
								/*
 | 
				
			||||||
			 * copy new GROUP if selected
 | 
								 * copy new GROUP if selected
 | 
				
			||||||
			 * or keep old GROUP if any
 | 
								 * or keep old GROUP if any
 | 
				
			||||||
| 
						 | 
					@ -4120,11 +4122,11 @@ static BOOL mergesecurityattr(ntfs_volume *vol, const char *oldattr,
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			size = sid_size(pgroup);
 | 
								size = sid_size(pgroup);
 | 
				
			||||||
			memcpy(&target[pos], pgroup, size);
 | 
								memcpy(&target[pos], pgroup, size);
 | 
				
			||||||
			targhead->group = pos;
 | 
								targhead->group = cpu_to_le32(pos);
 | 
				
			||||||
			pos += size;
 | 
								pos += size;
 | 
				
			||||||
		} else
 | 
							} else
 | 
				
			||||||
			targhead->group = 0;
 | 
								targhead->group = cpu_to_le32(0);
 | 
				
			||||||
		targhead->control = present | selection;
 | 
							targhead->control = cpu_to_le16(present | selection);
 | 
				
			||||||
		ok = !update_secur_descr(vol, target, ni);
 | 
							ok = !update_secur_descr(vol, target, ni);
 | 
				
			||||||
		free(target);
 | 
							free(target);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					@ -4207,7 +4209,7 @@ BOOL ntfs_set_file_security(struct SECURITY_API *scapi,
 | 
				
			||||||
	if (scapi && (scapi->magic == MAGIC_API) && attr) {
 | 
						if (scapi && (scapi->magic == MAGIC_API) && attr) {
 | 
				
			||||||
		phead = (const SECURITY_DESCRIPTOR_RELATIVE*)attr;
 | 
							phead = (const SECURITY_DESCRIPTOR_RELATIVE*)attr;
 | 
				
			||||||
		attrsz = attr_size(attr);
 | 
							attrsz = attr_size(attr);
 | 
				
			||||||
		provided = phead->control;
 | 
							provided = le16_to_cpu(phead->control);
 | 
				
			||||||
		if (phead->owner)
 | 
							if (phead->owner)
 | 
				
			||||||
			provided |= OWNER_SECURITY_INFORMATION;
 | 
								provided |= OWNER_SECURITY_INFORMATION;
 | 
				
			||||||
		if (phead->group)
 | 
							if (phead->group)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue