diff --git a/include/asprintf.h b/include/asprintf.h index 88c83cc0..8c4d804a 100644 --- a/include/asprintf.h +++ b/include/asprintf.h @@ -18,7 +18,7 @@ static inline int _vscprintf_so(const char * format, va_list pargs) { va_end(argcopy); return retval; } -#endif // _vscprintf +#endif /* _vscprintf */ #ifndef vasprintf static inline int vasprintf(char **strp, const char *fmt, va_list ap) { @@ -31,7 +31,7 @@ static inline int vasprintf(char **strp, const char *fmt, va_list ap) { *strp = str; return r; } -#endif // vasprintf +#endif /* vasprintf */ #ifndef asprintf static inline int asprintf(char *strp[], const char *fmt, ...) { @@ -41,6 +41,6 @@ static inline int asprintf(char *strp[], const char *fmt, ...) { va_end(ap); return r; } -#endif // asprintf +#endif /* asprintf */ -#endif // ! _ASPRINTF_H_ +#endif /* ! _ASPRINTF_H_ */ diff --git a/lib/alloc.c b/lib/alloc.c index 3a7741b5..fcff45f8 100644 --- a/lib/alloc.c +++ b/lib/alloc.c @@ -104,7 +104,7 @@ smb2_alloc_data(struct smb2_context *smb2, void *memctx, size_t size) const char* __mptr = memctx; hdr = (struct smb2_alloc_header*)((char *)__mptr - offsetof(struct smb2_alloc_header, buf)); } -#endif // !_MSC_VER +#endif /* !_MSC_VER */ ptr->next = hdr->mem; hdr->mem = ptr; @@ -129,7 +129,7 @@ smb2_free_data(struct smb2_context *smb2, void *ptr) const char* __mptr = ptr; hdr = (struct smb2_alloc_header*)((char *)__mptr - offsetof(struct smb2_alloc_header, buf)); } -#endif // !_MSC_VER +#endif /* !_MSC_VER */ while ((ent = hdr->mem)) { hdr->mem = ent->next; diff --git a/lib/dcerpc.c b/lib/dcerpc.c index 782b5e05..7d295e3e 100644 --- a/lib/dcerpc.c +++ b/lib/dcerpc.c @@ -1299,8 +1299,8 @@ dcerpc_decode_response(struct dcerpc_context *ctx, #else const char* __mptr = rsp; struct dcerpc_pdu *pdu = (struct dcerpc_pdu*)((char *)__mptr - offsetof(struct dcerpc_pdu, rsp)); -#endif // !_MSC_VER - +#endif /* !_MSC_VER */ + if (offset < 0) { return offset; } diff --git a/lib/errors.c b/lib/errors.c index 497f40e0..1ff4c02e 100644 --- a/lib/errors.c +++ b/lib/errors.c @@ -1159,13 +1159,17 @@ int nterror_to_errno(uint32_t status) { case SMB2_STATUS_CONNECTION_ABORTED: case SMB2_STATUS_NETWORK_NAME_DELETED: case SMB2_STATUS_INVALID_NETWORK_RESPONSE: - // We return this errno with the intention that caller can - // retry when any of these are received. + /* + ** We return this errno with the intention that caller can + ** retry when any of these are received. + */ return ENETRESET; case SMB2_STATUS_PATH_NOT_COVERED: - // We do not have an errno which can be an equivalent of this - // NT_STATUS code. To handle this, return a code which will not - // be used as we are operating over a network. + /* + ** We do not have an errno which can be an equivalent of this + ** NT_STATUS code. To handle this, return a code which will not + ** be used as we are operating over a network. + */ return ENOEXEC; case SMB2_STATUS_IO_TIMEOUT: return ETIMEDOUT; diff --git a/lib/init.c b/lib/init.c index 4b366342..75b04817 100644 --- a/lib/init.c +++ b/lib/init.c @@ -72,7 +72,7 @@ #define srandom srand #define random rand #define getpid GetCurrentProcessId -#endif // _MSC_VER +#endif /* _MSC_VER */ #ifdef ESP_PLATFORM #include @@ -84,11 +84,11 @@ #ifdef __ANDROID__ #include -// getlogin_r() was added in API 28 +/* getlogin_r() was added in API 28 */ #if __ANDROID_API__ < 28 #define getlogin_r(a,b) ENXIO #endif -#endif // __ANDROID__ +#endif /* __ANDROID__ */ static int smb2_parse_args(struct smb2_context *smb2, const char *args) @@ -483,7 +483,7 @@ static void smb2_set_password_from_file(struct smb2_context *smb2) int finished; #ifdef _MSC_UWP -// GetEnvironmentVariable is not available for UWP up to 10.0.16299 SDK +/* GetEnvironmentVariable is not available for UWP up to 10.0.16299 SDK */ #if defined(NTDDI_WIN10_RS3) && (NTDDI_VERSION >= NTDDI_WIN10_RS3) uint32_t name_len = GetEnvironmentVariableA("NTLM_USER_FILE", NULL, 0); if (name_len > 0) { diff --git a/lib/libsmb2.c b/lib/libsmb2.c index ee5b6c57..f048d755 100644 --- a/lib/libsmb2.c +++ b/lib/libsmb2.c @@ -118,15 +118,15 @@ static const char SMBAppKey[] = "SMBAppKey"; #ifndef O_ACCMODE #define O_ACCMODE (O_RDWR|O_WRONLY|O_RDONLY) -#endif // !O_ACCMODE +#endif /* !O_ACCMODE */ #ifndef O_SYNC #ifndef O_DSYNC #define O_DSYNC 040000 -#endif // !O_DSYNC +#endif /* !O_DSYNC */ #define __O_SYNC 020000000 #define O_SYNC (__O_SYNC|O_DSYNC) -#endif // !O_SYNC +#endif /* !O_SYNC */ const smb2_file_id compound_file_id = { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, diff --git a/lib/ntlmssp.c b/lib/ntlmssp.c index 39c20ce9..c8a16628 100644 --- a/lib/ntlmssp.c +++ b/lib/ntlmssp.c @@ -179,9 +179,9 @@ ntlm_negotiate_message(struct smb2_context *smb2, struct auth_data *auth_data) u32 = NTLMSSP_NEGOTIATE_128| NTLMSSP_NEGOTIATE_EXTENDED_SESSIONSECURITY| - //NTLMSSP_NEGOTIATE_ALWAYS_SIGN| + /* NTLMSSP_NEGOTIATE_ALWAYS_SIGN| */ NTLMSSP_NEGOTIATE_SEAL| - //NTLMSSP_NEGOTIATE_SIGN| + /* NTLMSSP_NEGOTIATE_SIGN| */ NTLMSSP_REQUEST_TARGET|NTLMSSP_NEGOTIATE_OEM| NTLMSSP_NEGOTIATE_UNICODE; u32 = htole32(u32); @@ -533,8 +533,9 @@ encode_ntlm_auth(struct smb2_context *smb2, time_t ti, /* negotiate flags */ u32 = NTLMSSP_NEGOTIATE_128| NTLMSSP_NEGOTIATE_EXTENDED_SESSIONSECURITY| - //NTLMSSP_NEGOTIATE_ALWAYS_SIGN| - //NTLMSSP_NEGOTIATE_SIGN| + /* NTLMSSP_NEGOTIATE_ALWAYS_SIGN| + NTLMSSP_NEGOTIATE_SIGN| + */ NTLMSSP_REQUEST_TARGET|NTLMSSP_NEGOTIATE_OEM| NTLMSSP_NEGOTIATE_UNICODE; if (anonymous) diff --git a/lib/sha384-512.c b/lib/sha384-512.c index 25657dcf..0fd14f7d 100644 --- a/lib/sha384-512.c +++ b/lib/sha384-512.c @@ -226,7 +226,6 @@ /* * add "length" to the length */ - #define SHA384_512AddLength(context, length) ( \ addTemp[3] = (length), SHA512_ADDTO4((context)->Length, addTemp), \ (context)->Corrupted = (((context)->Length[3] == 0) && \ diff --git a/lib/smb2-cmd-query-directory.c b/lib/smb2-cmd-query-directory.c index b5296730..8d21bb62 100644 --- a/lib/smb2-cmd-query-directory.c +++ b/lib/smb2-cmd-query-directory.c @@ -174,7 +174,7 @@ smb2_cmd_query_directory_async(struct smb2_context *smb2, /* Adjust credit charge for large payloads */ if (smb2->supports_multi_credit) { pdu->header.credit_charge = - (req->output_buffer_length - 1) / 65536 + 1; // 3.1.5.2 of [MS-SMB2] + (req->output_buffer_length - 1) / 65536 + 1; /* 3.1.5.2 of [MS-SMB2] */ } return pdu; diff --git a/lib/smb2-cmd-read.c b/lib/smb2-cmd-read.c index c31b5a73..dd6935bb 100644 --- a/lib/smb2-cmd-read.c +++ b/lib/smb2-cmd-read.c @@ -125,7 +125,7 @@ smb2_cmd_read_async(struct smb2_context *smb2, /* Adjust credit charge for large payloads */ if (smb2->supports_multi_credit) { - pdu->header.credit_charge = (req->length - 1) / 65536 + 1; // 3.1.5.2 of [MS-SMB2] + pdu->header.credit_charge = (req->length - 1) / 65536 + 1; /* 3.1.5.2 of [MS-SMB2] */ } return pdu; diff --git a/lib/smb2-cmd-write.c b/lib/smb2-cmd-write.c index 68112e81..1ac52f70 100644 --- a/lib/smb2-cmd-write.c +++ b/lib/smb2-cmd-write.c @@ -114,7 +114,7 @@ smb2_cmd_write_async(struct smb2_context *smb2, /* Adjust credit charge for large payloads */ if (smb2->supports_multi_credit) { - pdu->header.credit_charge = (req->length - 1) / 65536 + 1; // 3.1.5.2 of [MS-SMB2] + pdu->header.credit_charge = (req->length - 1) / 65536 + 1; /* 3.1.5.2 of [MS-SMB2] */ } return pdu; diff --git a/lib/smb3-seal.c b/lib/smb3-seal.c index be6ae9ac..1dd70549 100644 --- a/lib/smb3-seal.c +++ b/lib/smb3-seal.c @@ -59,7 +59,7 @@ #ifdef _MSC_VER #define random rand -#endif // _MSC_VER +#endif /* _MSC_VER */ #include diff --git a/lib/socket.c b/lib/socket.c index 8defc039..1578de15 100644 --- a/lib/socket.c +++ b/lib/socket.c @@ -963,28 +963,32 @@ static void interleave_addrinfo(struct addrinfo *base) struct addrinfo **next = &base->ai_next; while (*next) { struct addrinfo *cur = *next; - // Iterate forward until we find an entry of a different family. + /* Iterate forward until we find an entry of a different family. */ if (cur->ai_family == base->ai_family) { next = &cur->ai_next; continue; } if (cur == base->ai_next) { - // If the first one following base is of a different family, just - // move base forward one step and continue. + /* + ** If the first one following base is of a different family, just + ** move base forward one step and continue. + */ base = cur; next = &base->ai_next; continue; } - // Unchain cur from the rest of the list from its current spot. + /* Unchain cur from the rest of the list from its current spot. */ *next = cur->ai_next; - // Hook in cur directly after base. + /* Hook in cur directly after base. */ cur->ai_next = base->ai_next; base->ai_next = cur; - // Restart with a new base. We know that before moving the cur element, - // everything between the previous base and cur had the same family, - // different from cur->ai_family. Therefore, we can keep next pointing - // where it was, and continue from there with base at the one after - // cur. + /* + ** Restart with a new base. We know that before moving the cur element, + ** everything between the previous base and cur had the same family, + ** different from cur->ai_family. Therefore, we can keep next pointing + ** where it was, and continue from there with base at the one after + ** cur. + */ base = cur->ai_next; } }