diff options
author | TizenOpenSource <tizenopensrc@samsung.com> | 2024-01-22 15:24:08 +0900 |
---|---|---|
committer | TizenOpenSource <tizenopensrc@samsung.com> | 2024-01-22 15:24:08 +0900 |
commit | 59527f05008633a5909a30a57aa2014cff553cc7 (patch) | |
tree | d9c334e83692851c02e3e1b8e65570c97bc82481 /lib | |
parent | 6211adade47a2d94340d5c20dd737e8bdf246636 (diff) | |
download | rsync-upstream.tar.gz rsync-upstream.tar.bz2 rsync-upstream.zip |
Imported Upstream version 3.2.7upstream/3.2.7upstream
Diffstat (limited to 'lib')
-rw-r--r-- | lib/md-defines.h | 20 | ||||
-rw-r--r-- | lib/md5-asm-x86_64.S | 4 | ||||
-rw-r--r-- | lib/md5.c | 19 | ||||
-rw-r--r-- | lib/mdigest.h | 11 | ||||
-rw-r--r-- | lib/pool_alloc.c | 5 | ||||
-rw-r--r-- | lib/snprintf.c | 2 | ||||
-rw-r--r-- | lib/sysacls.c | 192 | ||||
-rw-r--r-- | lib/sysacls.h | 4 | ||||
-rw-r--r-- | lib/sysxattrs.c | 11 |
9 files changed, 143 insertions, 125 deletions
diff --git a/lib/md-defines.h b/lib/md-defines.h index 1410af5f..6ef6a689 100644 --- a/lib/md-defines.h +++ b/lib/md-defines.h @@ -1,11 +1,28 @@ /* Keep this simple so both C and ASM can use it */ +/* These allow something like CFLAGS=-DDISABLE_SHA512_DIGEST */ +#ifdef DISABLE_SHA256_DIGEST +#undef SHA256_DIGEST_LENGTH +#endif +#ifdef DISABLE_SHA512_DIGEST +#undef SHA512_DIGEST_LENGTH +#endif + #define MD4_DIGEST_LEN 16 #define MD5_DIGEST_LEN 16 +#if defined SHA512_DIGEST_LENGTH +#define MAX_DIGEST_LEN SHA512_DIGEST_LENGTH +#elif defined SHA256_DIGEST_LENGTH +#define MAX_DIGEST_LEN SHA256_DIGEST_LENGTH +#elif defined SHA_DIGEST_LENGTH +#define MAX_DIGEST_LEN SHA_DIGEST_LENGTH +#else #define MAX_DIGEST_LEN MD5_DIGEST_LEN +#endif #define CSUM_CHUNK 64 +#define CSUM_gone -1 #define CSUM_NONE 0 #define CSUM_MD4_ARCHAIC 1 #define CSUM_MD4_BUSTED 2 @@ -15,3 +32,6 @@ #define CSUM_XXH64 6 #define CSUM_XXH3_64 7 #define CSUM_XXH3_128 8 +#define CSUM_SHA1 9 +#define CSUM_SHA256 10 +#define CSUM_SHA512 11 diff --git a/lib/md5-asm-x86_64.S b/lib/md5-asm-x86_64.S index 383f193a..3737058f 100644 --- a/lib/md5-asm-x86_64.S +++ b/lib/md5-asm-x86_64.S @@ -27,7 +27,7 @@ #include "config.h" #include "md-defines.h" -#if !defined USE_OPENSSL && CSUM_CHUNK == 64 +#ifdef USE_MD5_ASM /* { */ #ifdef __APPLE__ #define md5_process_asm _md5_process_asm @@ -698,4 +698,4 @@ md5_process_asm: pop %rbp ret -#endif /* !USE_OPENSSL ... */ +#endif /* } USE_MD5_ASM */ @@ -2,7 +2,7 @@ * RFC 1321 compliant MD5 implementation * * Copyright (C) 2001-2003 Christophe Devine - * Copyright (C) 2007-2020 Wayne Davison + * Copyright (C) 2007-2022 Wayne Davison * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -20,7 +20,6 @@ #include "rsync.h" -#ifndef USE_OPENSSL void md5_begin(md_context *ctx) { ctx->A = 0x67452301; @@ -148,7 +147,10 @@ static void md5_process(md_context *ctx, const uchar data[CSUM_CHUNK]) ctx->D += D; } -#if defined HAVE_ASM && CSUM_CHUNK == 64 +#ifdef USE_MD5_ASM +#if CSUM_CHUNK != 64 +#error The MD5 ASM code does not support CSUM_CHUNK != 64 +#endif extern void md5_process_asm(md_context *ctx, const void *data, size_t num); #endif @@ -176,20 +178,20 @@ void md5_update(md_context *ctx, const uchar *input, uint32 length) left = 0; } -#if defined HAVE_ASM && CSUM_CHUNK == 64 +#ifdef USE_MD5_ASM /* { */ if (length >= CSUM_CHUNK) { uint32 chunks = length / CSUM_CHUNK; md5_process_asm(ctx, input, chunks); length -= chunks * CSUM_CHUNK; input += chunks * CSUM_CHUNK; } -#else +#else /* } { */ while (length >= CSUM_CHUNK) { md5_process(ctx, input); length -= CSUM_CHUNK; input += CSUM_CHUNK; } -#endif +#endif /* } */ if (length) memcpy(ctx->buffer + left, input, length); @@ -221,9 +223,8 @@ void md5_result(md_context *ctx, uchar digest[MD5_DIGEST_LEN]) SIVALu(digest, 8, ctx->C); SIVALu(digest, 12, ctx->D); } -#endif -#ifdef TEST_MD5 +#ifdef TEST_MD5 /* { */ void get_md5(uchar *out, const uchar *input, int n) { @@ -317,4 +318,4 @@ int main(int argc, char *argv[]) return 0; } -#endif +#endif /* } */ diff --git a/lib/mdigest.h b/lib/mdigest.h index db174017..9d52ef5f 100644 --- a/lib/mdigest.h +++ b/lib/mdigest.h @@ -1,8 +1,8 @@ /* The include file for both the MD4 and MD5 routines. */ #ifdef USE_OPENSSL -#include "openssl/md4.h" -#include "openssl/md5.h" +#include <openssl/sha.h> +#include <openssl/evp.h> #endif #include "md-defines.h" @@ -17,13 +17,6 @@ void mdfour_begin(md_context *md); void mdfour_update(md_context *md, const uchar *in, uint32 length); void mdfour_result(md_context *md, uchar digest[MD4_DIGEST_LEN]); -#ifndef USE_OPENSSL -#define MD5_CTX md_context -#define MD5_Init md5_begin -#define MD5_Update md5_update -#define MD5_Final(digest, cptr) md5_result(cptr, digest) - void md5_begin(md_context *ctx); void md5_update(md_context *ctx, const uchar *input, uint32 length); void md5_result(md_context *ctx, uchar digest[MD5_DIGEST_LEN]); -#endif diff --git a/lib/pool_alloc.c b/lib/pool_alloc.c index f6c6faf6..a1a7245f 100644 --- a/lib/pool_alloc.c +++ b/lib/pool_alloc.c @@ -9,8 +9,7 @@ struct alloc_pool size_t size; /* extent size */ size_t quantum; /* allocation quantum */ struct pool_extent *extents; /* top extent is "live" */ - void (*bomb)(); /* function to call if - * malloc fails */ + void (*bomb)(); /* called if malloc fails */ int flags; /* statistical data */ @@ -49,7 +48,7 @@ pool_create(size_t size, size_t quantum, void (*bomb)(const char*, const char*, { struct alloc_pool *pool; - if ((MINALIGN & (MINALIGN - 1)) != 0) { + if ((MINALIGN & (MINALIGN - 1)) != (0)) { if (bomb) (*bomb)("Compiler error: MINALIGN is not a power of 2", __FILE__, __LINE__); return NULL; diff --git a/lib/snprintf.c b/lib/snprintf.c index 52fdd11f..15c0529d 100644 --- a/lib/snprintf.c +++ b/lib/snprintf.c @@ -20,7 +20,7 @@ * for string length. This covers a nasty loophole. * * The other functions are there to prevent NULL pointers from - * causing nast effects. + * causing nasty effects. * * More Recently: * Brandon Long <blong@fiction.net> 9/15/96 for mutt 0.43 diff --git a/lib/sysacls.c b/lib/sysacls.c index c23864fe..a5abe408 100644 --- a/lib/sysacls.c +++ b/lib/sysacls.c @@ -2,7 +2,7 @@ * Unix SMB/CIFS implementation. * Based on the Samba ACL support code. * Copyright (C) Jeremy Allison 2000. - * Copyright (C) 2007-2020 Wayne Davison + * Copyright (C) 2007-2022 Wayne Davison * * The permission functions have been changed to get/set all bits via * one call. Some functions that rsync doesn't need were also removed. @@ -175,7 +175,7 @@ int sys_acl_delete_def_file(const char *name) return acl_delete_def_file(name); } -int sys_acl_free_acl(SMB_ACL_T the_acl) +int sys_acl_free_acl(SMB_ACL_T the_acl) { return acl_free(the_acl); } @@ -185,7 +185,7 @@ int sys_acl_free_acl(SMB_ACL_T the_acl) * The interface to DEC/Compaq Tru64 UNIX ACLs * is based on Draft 13 of the POSIX spec which is * slightly different from the Draft 16 interface. - * + * * Also, some of the permset manipulation functions * such as acl_clear_perm() and acl_add_perm() appear * to be broken on Tru64 so we have to manipulate @@ -310,7 +310,7 @@ int sys_acl_delete_def_file(const char *name) return acl_delete_def_file((char *)name); } -int sys_acl_free_acl(SMB_ACL_T the_acl) +int sys_acl_free_acl(SMB_ACL_T the_acl) { return acl_free(the_acl); } @@ -457,7 +457,7 @@ SMB_ACL_T sys_acl_get_file(const char *path_p, SMB_ACL_TYPE_T type) break; } ndefault = count - naccess; - + /* * if the caller wants the default ACL we have to copy * the entries down to the start of the acl[] buffer @@ -517,7 +517,7 @@ SMB_ACL_T sys_acl_get_fd(int fd) if (acl_d->acl[naccess].a_type & ACL_DEFAULT) break; } - + acl_d->count = naccess; return acl_d; @@ -532,7 +532,7 @@ int sys_acl_get_info(SMB_ACL_ENTRY_T entry, SMB_ACL_TAG_T *tag_type_p, uint32 *b if (*tag_type_p == SMB_ACL_USER || *tag_type_p == SMB_ACL_GROUP) *u_g_id_p = entry->a_id; - + return 0; } @@ -633,7 +633,7 @@ static int acl_sort(SMB_ACL_T acl_d) } return 0; } - + int sys_acl_valid(SMB_ACL_T acl_d) { return acl_sort(acl_d); @@ -755,11 +755,11 @@ int sys_acl_delete_def_file(const char *path) ret = acl(path, SETACL, acl_d->count, acl_d->acl); sys_acl_free_acl(acl_d); - + return ret; } -int sys_acl_free_acl(SMB_ACL_T acl_d) +int sys_acl_free_acl(SMB_ACL_T acl_d) { SAFE_FREE(acl_d); return 0; @@ -895,10 +895,10 @@ SMB_ACL_T sys_acl_get_file(const char *path_p, SMB_ACL_TYPE_T type) int ndefault; /* # of default ACL entries */ if (hpux_acl_call_presence() == False) { - /* Looks like we don't have the acl() system call on HPUX. + /* Looks like we don't have the acl() system call on HPUX. * May be the system doesn't have the latest version of JFS. */ - return NULL; + return NULL; } if (type != SMB_ACL_TYPE_ACCESS && type != SMB_ACL_TYPE_DEFAULT) { @@ -949,7 +949,7 @@ SMB_ACL_T sys_acl_get_file(const char *path_p, SMB_ACL_TYPE_T type) break; } ndefault = count - naccess; - + /* * if the caller wants the default ACL we have to copy * the entries down to the start of the acl[] buffer @@ -1109,9 +1109,9 @@ struct hpux_acl_types { * aclp - Array of ACL structures. * acl_type_count - Pointer to acl_types structure. Should already be * allocated. - * Output: + * Output: * - * acl_type_count - This structure is filled up with counts of various + * acl_type_count - This structure is filled up with counts of various * acl types. */ @@ -1123,28 +1123,28 @@ static void hpux_count_obj(int acl_count, struct acl *aclp, struct hpux_acl_type for (i = 0; i < acl_count; i++) { switch (aclp[i].a_type) { - case USER: + case USER: acl_type_count->n_user++; break; - case USER_OBJ: + case USER_OBJ: acl_type_count->n_user_obj++; break; - case DEF_USER_OBJ: + case DEF_USER_OBJ: acl_type_count->n_def_user_obj++; break; - case GROUP: + case GROUP: acl_type_count->n_group++; break; - case GROUP_OBJ: + case GROUP_OBJ: acl_type_count->n_group_obj++; break; - case DEF_GROUP_OBJ: + case DEF_GROUP_OBJ: acl_type_count->n_def_group_obj++; break; - case OTHER_OBJ: + case OTHER_OBJ: acl_type_count->n_other_obj++; break; - case DEF_OTHER_OBJ: + case DEF_OTHER_OBJ: acl_type_count->n_def_other_obj++; break; case CLASS_OBJ: @@ -1159,14 +1159,14 @@ static void hpux_count_obj(int acl_count, struct acl *aclp, struct hpux_acl_type case DEF_GROUP: acl_type_count->n_def_group++; break; - default: + default: acl_type_count->n_illegal_obj++; break; } } } -/* swap_acl_entries: Swaps two ACL entries. +/* swap_acl_entries: Swaps two ACL entries. * * Inputs: aclp0, aclp1 - ACL entries to be swapped. */ @@ -1189,25 +1189,25 @@ static void hpux_swap_acl_entries(struct acl *aclp0, struct acl *aclp1) } /* prohibited_duplicate_type - * Identifies if given ACL type can have duplicate entries or + * Identifies if given ACL type can have duplicate entries or * not. * * Inputs: acl_type - ACL Type. * - * Outputs: + * Outputs: * - * Return.. + * Return.. * * True - If the ACL type matches any of the prohibited types. * False - If the ACL type doesn't match any of the prohibited types. - */ + */ static BOOL hpux_prohibited_duplicate_type(int acl_type) { switch (acl_type) { case USER: case GROUP: - case DEF_USER: + case DEF_USER: case DEF_GROUP: return True; default: @@ -1217,7 +1217,7 @@ static BOOL hpux_prohibited_duplicate_type(int acl_type) /* get_needed_class_perm * Returns the permissions of a ACL structure only if the ACL - * type matches one of the pre-determined types for computing + * type matches one of the pre-determined types for computing * CLASS_OBJ permissions. * * Inputs: aclp - Pointer to ACL structure. @@ -1226,17 +1226,17 @@ static BOOL hpux_prohibited_duplicate_type(int acl_type) static int hpux_get_needed_class_perm(struct acl *aclp) { switch (aclp->a_type) { - case USER: - case GROUP_OBJ: - case GROUP: - case DEF_USER_OBJ: + case USER: + case GROUP_OBJ: + case GROUP: + case DEF_USER_OBJ: case DEF_USER: - case DEF_GROUP_OBJ: + case DEF_GROUP_OBJ: case DEF_GROUP: case DEF_CLASS_OBJ: - case DEF_OTHER_OBJ: + case DEF_OTHER_OBJ: return aclp->a_perm; - default: + default: return 0; } } @@ -1267,15 +1267,15 @@ static int hpux_acl_sort(int acl_count, int calclass, struct acl *aclp) #if !defined(HAVE_HPUX_ACLSORT) /* * The aclsort() system call is available on the latest HPUX General - * Patch Bundles. So for HPUX, we developed our version of acl_sort - * function. Because, we don't want to update to a new + * Patch Bundles. So for HPUX, we developed our version of acl_sort + * function. Because, we don't want to update to a new * HPUX GR bundle just for aclsort() call. */ struct hpux_acl_types acl_obj_count; int n_class_obj_perm = 0; int i, j; - + if (!acl_count) { DEBUG(10, ("Zero acl count passed. Returning Success\n")); return 0; @@ -1290,8 +1290,8 @@ static int hpux_acl_sort(int acl_count, int calclass, struct acl *aclp) hpux_count_obj(acl_count, aclp, &acl_obj_count); - /* There should be only one entry each of type USER_OBJ, GROUP_OBJ, - * CLASS_OBJ and OTHER_OBJ + /* There should be only one entry each of type USER_OBJ, GROUP_OBJ, + * CLASS_OBJ and OTHER_OBJ */ if (acl_obj_count.n_user_obj != 1 @@ -1313,15 +1313,15 @@ or DEF_USER_OBJ or DEF_GROUP_OBJ or DEF_OTHER_OBJ\n")); return -1; } - /* We now have proper number of OBJ and DEF_OBJ entries. Now sort the acl - * structures. + /* We now have proper number of OBJ and DEF_OBJ entries. Now sort the acl + * structures. * * Sorting crieteria - First sort by ACL type. If there are multiple entries of * same ACL type, sort by ACL id. * - * I am using the trivial kind of sorting method here because, performance isn't + * I am using the trivial kind of sorting method here because, performance isn't * really effected by the ACLs feature. More over there aren't going to be more - * than 17 entries on HPUX. + * than 17 entries on HPUX. */ for (i = 0; i < acl_count; i++) { @@ -1390,7 +1390,7 @@ static int acl_sort(SMB_ACL_T acl_d) } return 0; } - + int sys_acl_valid(SMB_ACL_T acl_d) { return acl_sort(acl_d); @@ -1405,11 +1405,11 @@ int sys_acl_set_file(const char *name, SMB_ACL_TYPE_T type, SMB_ACL_T acl_d) int ret; if (hpux_acl_call_presence() == False) { - /* Looks like we don't have the acl() system call on HPUX. + /* Looks like we don't have the acl() system call on HPUX. * May be the system doesn't have the latest version of JFS. */ errno=ENOSYS; - return -1; + return -1; } if (type != SMB_ACL_TYPE_ACCESS && type != SMB_ACL_TYPE_DEFAULT) { @@ -1538,11 +1538,11 @@ int sys_acl_delete_def_file(const char *path) ret = acl(path, ACL_SET, acl_d->count, acl_d->acl); sys_acl_free_acl(acl_d); - + return ret; } -int sys_acl_free_acl(SMB_ACL_T acl_d) +int sys_acl_free_acl(SMB_ACL_T acl_d) { free(acl_d); return 0; @@ -1723,7 +1723,7 @@ int sys_acl_delete_def_file(const char *name) return acl_delete_def_file(name); } -int sys_acl_free_acl(SMB_ACL_T acl_d) +int sys_acl_free_acl(SMB_ACL_T acl_d) { if (acl_d->freeaclp) { acl_free(acl_d->aclp); @@ -1739,7 +1739,6 @@ int sys_acl_free_acl(SMB_ACL_T acl_d) int sys_acl_get_entry(SMB_ACL_T theacl, int entry_id, SMB_ACL_ENTRY_T *entry_p) { struct acl_entry_link *link; - struct new_acl_entry *entry; int keep_going; if (entry_id == SMB_ACL_FIRST_ENTRY) @@ -1765,10 +1764,15 @@ int sys_acl_get_entry(SMB_ACL_T theacl, int entry_id, SMB_ACL_ENTRY_T *entry_p) for (keep_going = 0; keep_going < theacl->count; keep_going++) link = link->nextp; - entry = *entry_p = link->entryp; + *entry_p = link->entryp; - DEBUG(10, ("*entry_p is %d\n", entry_p)); - DEBUG(10, ("*entry_p->ace_access is %d\n", entry->ace_access)); +#if 0 + { + struct new_acl_entry *entry = *entry_p; + DEBUG(10, ("*entry_p is %lx\n", (long)entry)); + DEBUG(10, ("*entry_p->ace_access is %d\n", entry->ace_access)); + } +#endif /* Increment count */ theacl->count++; @@ -1830,12 +1834,12 @@ SMB_ACL_T sys_acl_get_file(const char *path_p, SMB_ACL_TYPE_T type) } /* Get the acl using statacl */ - + DEBUG(10, ("Entering sys_acl_get_file\n")); DEBUG(10, ("path_p is %s\n", path_p)); file_acl = (struct acl *)SMB_MALLOC(BUFSIZ); - + if (file_acl == NULL) { errno=ENOMEM; DEBUG(0, ("Error in AIX sys_acl_get_file: %d\n", errno)); @@ -1927,9 +1931,9 @@ SMB_ACL_T sys_acl_get_file(const char *path_p, SMB_ACL_TYPE_T type) * to be specified but, it's better than leaving it 0 */ acl_entry_link->entryp->ace_type = acl_entry->ace_type; - + acl_entry_link->entryp->ace_access = acl_entry->ace_access; - + memcpy(acl_entry_link->entryp->ace_id, idp, sizeof (struct ace_id)); /* The access in the acl entries must be left shifted by * @@ -1958,7 +1962,7 @@ SMB_ACL_T sys_acl_get_file(const char *path_p, SMB_ACL_TYPE_T type) DEBUG(10, ("acl_entry = %d\n", acl_entry)); DEBUG(10, ("The ace_type is %d\n", acl_entry->ace_type)); - + acl_entry = acl_nxt(acl_entry); } } /* end of if enabled */ @@ -2010,12 +2014,12 @@ SMB_ACL_T sys_acl_get_file(const char *path_p, SMB_ACL_TYPE_T type) new_acl_entry->ace_access = file_acl->o_access << 6; idp->id_type = SMB_ACL_OTHER; break; - + case 1: new_acl_entry->ace_access = file_acl->u_access << 6; idp->id_type = SMB_ACL_USER_OBJ; break; - + default: return NULL; @@ -2044,7 +2048,7 @@ SMB_ACL_T sys_acl_get_fd(int fd) int rc = 0; /* Get the acl using fstatacl */ - + DEBUG(10, ("Entering sys_acl_get_fd\n")); DEBUG(10, ("fd is %d\n", fd)); file_acl = (struct acl *)SMB_MALLOC(BUFSIZ); @@ -2091,12 +2095,12 @@ SMB_ACL_T sys_acl_get_fd(int fd) DEBUG(10, ("acl_entry is %d\n", acl_entry)); DEBUG(10, ("acl_last(file_acl) id %d\n", acl_last(file_acl))); - + /* Check if the extended acl bit is on. * * If it isn't, do not show the * * contents of the acl since AIX intends * * the extended info to remain unused */ - + if (file_acl->acl_mode & S_IXACL){ /* while we are not pointing to the very end */ while (acl_entry < acl_last(file_acl)) { @@ -2111,7 +2115,7 @@ SMB_ACL_T sys_acl_get_fd(int fd) } idp = acl_entry->ace_id; - + /* Check if this is the first entry in the linked list. * * The first entry needs to keep prevp pointing to NULL * * and already has entryp allocated. */ @@ -2173,7 +2177,7 @@ SMB_ACL_T sys_acl_get_fd(int fd) DEBUG(10, ("acl_entry = %d\n", acl_entry)); DEBUG(10, ("The ace_type is %d\n", acl_entry->ace_type)); - + acl_entry = acl_nxt(acl_entry); } } /* end of if enabled */ @@ -2206,43 +2210,43 @@ SMB_ACL_T sys_acl_get_fd(int fd) } acl_entry_link->nextp = NULL; - + new_acl_entry = acl_entry_link->entryp; idp = new_acl_entry->ace_id; - + new_acl_entry->ace_len = sizeof (struct acl_entry); new_acl_entry->ace_type = ACC_PERMIT; idp->id_len = sizeof (struct ace_id); DEBUG(10, ("idp->id_len = %d\n", idp->id_len)); memset(idp->id_data, 0, sizeof (uid_t)); - + switch (i) { case 2: new_acl_entry->ace_access = file_acl->g_access << 6; idp->id_type = SMB_ACL_GROUP_OBJ; break; - + case 3: new_acl_entry->ace_access = file_acl->o_access << 6; idp->id_type = SMB_ACL_OTHER; break; - + case 1: new_acl_entry->ace_access = file_acl->u_access << 6; idp->id_type = SMB_ACL_USER_OBJ; break; - + default: return NULL; } - + acl_entry_link_head->count++; DEBUG(10, ("new_acl_entry->ace_access = %d\n", new_acl_entry->ace_access)); } acl_entry_link_head->count = 0; SAFE_FREE(file_acl); - + return acl_entry_link_head; } #endif @@ -2270,7 +2274,7 @@ int sys_acl_get_info(SMB_ACL_ENTRY_T entry, SMB_ACL_TAG_T *tag_type_p, uint32 *b SMB_ACL_T sys_acl_init(int count) { struct acl_entry_link *theacl = NULL; - + if (count < 0) { errno = EINVAL; return NULL; @@ -2297,7 +2301,7 @@ int sys_acl_create_entry(SMB_ACL_T *pacl, SMB_ACL_ENTRY_T *pentry) { struct acl_entry_link *theacl; struct acl_entry_link *acl_entryp; - struct acl_entry_link *temp_entry; + struct acl_entry_link *temp_entry = NULL; int counting; DEBUG(10, ("Entering the sys_acl_create_entry\n")); @@ -2379,9 +2383,9 @@ int sys_acl_valid(SMB_ACL_T theacl) } DEBUG(10, ("user_obj=%d, group_obj=%d, other_obj=%d\n", user_obj, group_obj, other_obj)); - + if (user_obj != 1 || group_obj != 1 || other_obj != 1) - return -1; + return -1; return 0; } @@ -2400,7 +2404,7 @@ int sys_acl_set_file(const char *name, SMB_ACL_TYPE_T acltype, SMB_ACL_T theacl) DEBUG(10, ("Entering sys_acl_set_file\n")); DEBUG(10, ("File name is %s\n", name)); - + /* AIX has no default ACL */ if (acltype == SMB_ACL_TYPE_DEFAULT) return 0; @@ -2445,7 +2449,7 @@ int sys_acl_set_file(const char *name, SMB_ACL_TYPE_T acltype, SMB_ACL_T theacl) errno = ENOMEM; DEBUG(0, ("Error in sys_acl_set_file is %d\n", errno)); return -1; - } + } memcpy(file_acl_temp, file_acl, file_acl->acl_len); SAFE_FREE(file_acl); @@ -2456,15 +2460,15 @@ int sys_acl_set_file(const char *name, SMB_ACL_TYPE_T acltype, SMB_ACL_T theacl) file_acl->acl_len += sizeof (struct acl_entry); acl_entry->ace_len = acl_entry_link->entryp->ace_len; acl_entry->ace_access = acl_entry_link->entryp->ace_access; - + /* In order to use this, we'll need to wait until we can get denies */ /* if (!acl_entry->ace_access && acl_entry->ace_type == ACC_PERMIT) acl_entry->ace_type = ACC_SPECIFY; */ acl_entry->ace_type = ACC_SPECIFY; - + ace_id = acl_entry->ace_id; - + ace_id->id_type = acl_entry_link->entryp->ace_id->id_type; DEBUG(10, ("The id type is %d\n", ace_id->id_type)); ace_id->id_len = acl_entry_link->entryp->ace_id->id_len; @@ -2492,7 +2496,7 @@ int sys_acl_set_fd(int fd, SMB_ACL_T theacl) uint user_id; uint acl_length; uint rc; - + DEBUG(10, ("Entering sys_acl_set_fd\n")); acl_length = BUFSIZ; file_acl = (struct acl *)SMB_MALLOC(BUFSIZ); @@ -2504,7 +2508,7 @@ int sys_acl_set_fd(int fd, SMB_ACL_T theacl) } memset(file_acl, 0, BUFSIZ); - + file_acl->acl_len = ACL_SIZ; file_acl->acl_mode = S_IXACL; @@ -2546,22 +2550,22 @@ int sys_acl_set_fd(int fd, SMB_ACL_T theacl) file_acl->acl_len += sizeof (struct acl_entry); acl_entry->ace_len = acl_entry_link->entryp->ace_len; acl_entry->ace_access = acl_entry_link->entryp->ace_access; - + /* In order to use this, we'll need to wait until we can get denies */ /* if (!acl_entry->ace_access && acl_entry->ace_type == ACC_PERMIT) acl_entry->ace_type = ACC_SPECIFY; */ - + acl_entry->ace_type = ACC_SPECIFY; - + ace_id = acl_entry->ace_id; - + ace_id->id_type = acl_entry_link->entryp->ace_id->id_type; DEBUG(10, ("The id type is %d\n", ace_id->id_type)); ace_id->id_len = acl_entry_link->entryp->ace_id->id_len; memcpy(&user_id, acl_entry_link->entryp->ace_id->id_data, sizeof (uid_t)); memcpy(ace_id->id_data, &user_id, sizeof (uid_t)); } - + rc = fchacl(fd, file_acl, file_acl->acl_len); DEBUG(10, ("errno is %d\n", errno)); DEBUG(10, ("return code is %d\n", rc)); @@ -2590,7 +2594,7 @@ int sys_acl_free_acl(SMB_ACL_T posix_acl) SAFE_FREE(acl_entry_link->prevp); SAFE_FREE(acl_entry_link->entryp); SAFE_FREE(acl_entry_link); - + return 0; } diff --git a/lib/sysacls.h b/lib/sysacls.h index 8865dae4..c0695974 100644 --- a/lib/sysacls.h +++ b/lib/sysacls.h @@ -3,7 +3,7 @@ * Version 2.2.x * Portable SMB ACL interface * Copyright (C) Jeremy Allison 2000 - * Copyright (C) 2007-2020 Wayne Davison + * Copyright (C) 2007-2022 Wayne Davison * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -232,7 +232,7 @@ struct new_acl_entry{ #define SMB_ACL_ENTRY_T struct new_acl_entry* #define SMB_ACL_T struct acl_entry_link* - + #define SMB_ACL_TAG_T unsigned short #define SMB_ACL_TYPE_T int diff --git a/lib/sysxattrs.c b/lib/sysxattrs.c index 583b93e9..ca08d131 100644 --- a/lib/sysxattrs.c +++ b/lib/sysxattrs.c @@ -2,7 +2,7 @@ * Extended attribute support for rsync. * * Copyright (C) 2004 Red Hat, Inc. - * Copyright (C) 2003-2019 Wayne Davison + * Copyright (C) 2003-2022 Wayne Davison * Written by Jay Fenlason. * * This program is free software; you can redistribute it and/or modify @@ -67,7 +67,7 @@ ssize_t sys_lgetxattr(const char *path, const char *name, void *value, size_t si u_int32_t offset = len; size_t data_retrieved = len; while (data_retrieved < size) { - len = getxattr(path, name, value + offset, size - data_retrieved, offset, XATTR_NOFOLLOW); + len = getxattr(path, name, (char*)value + offset, size - data_retrieved, offset, XATTR_NOFOLLOW); if (len <= 0) break; data_retrieved += len; @@ -167,7 +167,7 @@ static ssize_t read_xattr(int attrfd, void *buf, size_t buflen) } else { size_t bufpos; for (bufpos = 0; bufpos < sb.st_size; ) { - ssize_t cnt = read(attrfd, buf + bufpos, sb.st_size - bufpos); + ssize_t cnt = read(attrfd, (char*)buf + bufpos, sb.st_size - bufpos); if (cnt <= 0) { if (cnt < 0 && errno == EINTR) continue; @@ -218,7 +218,7 @@ int sys_lsetxattr(const char *path, const char *name, const void *value, size_t return -1; for (bufpos = 0; bufpos < size; ) { - ssize_t cnt = write(attrfd, value+bufpos, size); + ssize_t cnt = write(attrfd, (char*)value + bufpos, size); if (cnt <= 0) { if (cnt < 0 && errno == EINTR) continue; @@ -274,7 +274,8 @@ ssize_t sys_llistxattr(const char *path, char *list, size_t size) && (dp->d_name[10] == 'o' || dp->d_name[10] == 'w')) continue; - if ((ret += len+1) > size) { + ret += len + 1; + if ((size_t)ret > size) { if (size == 0) continue; ret = -1; |