Merge branch 'master' into lock

This commit is contained in:
Ben RUBSON 2017-11-02 10:40:45 +01:00 committed by GitHub
commit 939473322d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 47 additions and 35 deletions

View File

@ -166,7 +166,7 @@ if (ENABLE_NLS)
endif (ENABLE_NLS)
if (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 3.5) # Need 3.6 or above.
find_program(CLANG_TIDY_EXE NAMES "clang-tidy" "clang-tidy-4.0" DOC "Path to clang-tidy executable")
find_program(CLANG_TIDY_EXE NAMES "clang-tidy-4.0" "clang-tidy40" "clang-tidy" DOC "Path to clang-tidy executable")
if(NOT CLANG_TIDY_EXE)
message(STATUS "clang-tidy not found.")
else()
@ -179,8 +179,6 @@ if (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 3.5) # Need 3.6 or abo
",-google-readability-todo"
",-google-runtime-int"
",-google-runtime-references"
",-misc-misplaced-widening-cast"
",-misc-unused-parameters"
",-modernize-loop-convert"
",-readability-inconsistent-declaration-parameter-name"
",-readability-named-parameter"

View File

@ -251,7 +251,7 @@ ssize_t BlockFileIO::write(const IORequest &req) {
unsigned char *inPtr = req.data;
while (size != 0u) {
blockReq.offset = blockNum * _blockSize;
int toCopy = min((size_t)(_blockSize - partialOffset), size);
size_t toCopy = min((size_t)_blockSize - (size_t)partialOffset, size);
// if writing an entire block, or writing a partial block that requires
// no merging with existing data..

View File

@ -644,7 +644,7 @@ static Cipher::CipherAlgorithm selectCipherAlgorithm() {
cout << "\n" << _("Enter the number corresponding to your choice: ");
char answer[10];
char *res = fgets(answer, sizeof(answer), stdin);
int cipherNum = (res == nullptr ? 0 : atoi(answer));
int cipherNum = (res == nullptr ? 0 : (int)strtol(answer, nullptr, 10));
cout << "\n";
if (cipherNum < 1 || cipherNum > (int)algorithms.size()) {
@ -688,7 +688,7 @@ static Interface selectNameCoding() {
cout << "\n" << _("Enter the number corresponding to your choice: ");
char answer[10];
char *res = fgets(answer, sizeof(answer), stdin);
int algNum = (res == nullptr ? 0 : atoi(answer));
int algNum = (res == nullptr ? 0 : (int)strtol(answer, nullptr, 10));
cout << "\n";
if (algNum < 1 || algNum > (int)algorithms.size()) {
@ -755,7 +755,7 @@ static int selectKeySize(const Cipher::CipherAlgorithm &alg) {
char answer[10];
char *res = fgets(answer, sizeof(answer), stdin);
int keySize = (res == nullptr ? 0 : atoi(answer));
int keySize = (res == nullptr ? 0 : (int)strtol(answer, nullptr, 10));
cout << "\n";
keySize = alg.keyLength.closest(keySize);
@ -795,8 +795,8 @@ static int selectBlockSize(const Cipher::CipherAlgorithm &alg) {
char *res = fgets(answer, sizeof(answer), stdin);
cout << "\n";
if (res != nullptr && atoi(answer) >= alg.blockSize.min()) {
blockSize = atoi(answer);
if (res != nullptr && (int)strtol(answer, nullptr, 10) >= alg.blockSize.min()) {
blockSize = (int)strtol(answer, nullptr, 10);
}
blockSize = alg.blockSize.closest(blockSize);
@ -900,7 +900,7 @@ static void selectBlockMAC(int *macBytes, int *macRandBytes, bool forceMac) {
char *res = fgets(answer, sizeof(answer), stdin);
cout << "\n";
randSize = (res == nullptr ? 0 : atoi(answer));
randSize = (res == nullptr ? 0 : (int)strtol(answer, nullptr, 10));
if (randSize < 0) {
randSize = 0;
}

View File

@ -33,7 +33,7 @@
#include <openssl/buffer.h>
#define BLOCKDATA(BLOCK) (unsigned char *)BLOCK->data->data
#define BLOCKDATA(BLOCK) (unsigned char *)(BLOCK)->data->data
namespace encfs {

View File

@ -301,11 +301,11 @@ SSLKey::SSLKey(int keySize_, int ivLength_) {
this->ivLength = ivLength_;
pthread_mutex_init(&mutex, nullptr);
buffer = (unsigned char *)OPENSSL_malloc(keySize + ivLength);
memset(buffer, 0, keySize + ivLength);
memset(buffer, 0, (size_t)keySize + (size_t)ivLength);
// most likely fails unless we're running as root, or a user-page-lock
// kernel patch is applied..
mlock(buffer, keySize + ivLength);
mlock(buffer, (size_t)keySize + (size_t)ivLength);
block_enc = EVP_CIPHER_CTX_new();
EVP_CIPHER_CTX_init(block_enc);
@ -320,10 +320,10 @@ SSLKey::SSLKey(int keySize_, int ivLength_) {
}
SSLKey::~SSLKey() {
memset(buffer, 0, keySize + ivLength);
memset(buffer, 0, (size_t)keySize + (size_t)ivLength);
OPENSSL_free(buffer);
munlock(buffer, keySize + ivLength);
munlock(buffer, (size_t)keySize + (size_t)ivLength);
keySize = 0;
ivLength = 0;
@ -593,7 +593,7 @@ CipherKey SSL_Cipher::readKey(const unsigned char *data,
checksum = (checksum << 8) | (unsigned int)data[i];
}
memcpy(tmpBuf, data + KEY_CHECKSUM_BYTES, _keySize + _ivLength);
memcpy(tmpBuf, data + KEY_CHECKSUM_BYTES, (size_t)_keySize + (size_t)_ivLength);
streamDecode(tmpBuf, _keySize + _ivLength, checksum, masterKey);
// check for success
@ -608,7 +608,7 @@ CipherKey SSL_Cipher::readKey(const unsigned char *data,
std::shared_ptr<SSLKey> key(new SSLKey(_keySize, _ivLength));
memcpy(key->buffer, tmpBuf, _keySize + _ivLength);
memcpy(key->buffer, tmpBuf, (size_t)_keySize + (size_t)_ivLength);
memset(tmpBuf, 0, sizeof(tmpBuf));
initKey(key, _blockCipher, _streamCipher, _keySize);
@ -652,7 +652,7 @@ bool SSL_Cipher::compareKey(const CipherKey &A, const CipherKey &B) const {
rAssert(key1->keySize == _keySize);
rAssert(key2->keySize == _keySize);
return memcmp(key1->buffer, key2->buffer, _keySize + _ivLength) == 0;
return memcmp(key1->buffer, key2->buffer, (size_t)_keySize + (size_t)_ivLength) == 0;
}
int SSL_Cipher::encodedKeySize() const {

View File

@ -23,6 +23,7 @@
#include <algorithm> // for remove_if
#include <cstring> // for NULL
#include <fstream> // for ifstream
#include <limits>
#include <memory> // for shared_ptr
#include <sstream> // for ostringstream
@ -60,7 +61,15 @@ bool XmlValue::read(const char *path, int *out) const {
return false;
}
*out = atoi(value->text().c_str());
char * e;
long lout = strtol(value->text().c_str(), &e, 10);
if (*e != '\0') {
return false;
}
if (lout < std::numeric_limits<int>::min() || lout > std::numeric_limits<int>::max()) {
return false;
}
*out = (int)lout;
return true;
}
@ -70,8 +79,9 @@ bool XmlValue::read(const char *path, long *out) const {
return false;
}
*out = atol(value->text().c_str());
return true;
char * e;
*out = strtol(value->text().c_str(), &e, 10);
return (*e == '\0');
}
bool XmlValue::read(const char *path, double *out) const {
@ -80,8 +90,9 @@ bool XmlValue::read(const char *path, double *out) const {
return false;
}
*out = atof(value->text().c_str());
return true;
char * e;
*out = strtod(value->text().c_str(), &e);
return (*e == '\0');
}
bool XmlValue::read(const char *path, bool *out) const {
@ -90,8 +101,9 @@ bool XmlValue::read(const char *path, bool *out) const {
return false;
}
*out = (atoi(value->text().c_str()) != 0);
return true;
char * e;
*out = (strtol(value->text().c_str(), &e, 10) != 0);
return (*e == '\0');
}
bool XmlValue::readB64(const char *path, unsigned char *data,
@ -154,7 +166,7 @@ class XmlNode : virtual public XmlValue {
const tinyxml2::XMLElement *element;
public:
XmlNode(const tinyxml2::XMLElement *element_)
explicit XmlNode(const tinyxml2::XMLElement *element_)
: XmlValue(safeValueForNode(element_)), element(element_) {}
~XmlNode() override = default;

View File

@ -48,8 +48,8 @@ class autosprintf {
/* Destructor: frees the temporarily allocated string. */
~autosprintf();
/* Conversion to string. */
operator char*() const;
operator std::string() const;
explicit operator char*() const;
explicit operator std::string() const;
/* Output to an ostream. */
friend inline std::ostream& operator<<(std::ostream& stream,
const autosprintf& tmp) {

View File

@ -252,7 +252,7 @@ bool B64StandardDecode(unsigned char *out, const unsigned char *in, int inLen) {
// If you want to use an alternate alphabet, change the characters here
const static char encodeLookup[] =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
std::string B64StandardEncode(std::vector<unsigned char> inputBuffer) {
std::string B64StandardEncode(const std::vector<unsigned char> &inputBuffer) {
std::string encodedString;
encodedString.reserve(B256ToB64Bytes(inputBuffer.size()));
long temp;

View File

@ -73,7 +73,7 @@ void AsciiToB32(unsigned char *out, const unsigned char *in, int length);
bool B64StandardDecode(unsigned char *out, const unsigned char *in,
int inputLen);
std::string B64StandardEncode(std::vector<unsigned char> input);
std::string B64StandardEncode(const std::vector<unsigned char> &input);
} // namespace encfs

View File

@ -135,7 +135,7 @@ static void checkCanary(const std::shared_ptr<FileNode> &fnode) {
// helper function -- apply a functor to a node
static int withFileNode(const char *opName, const char *path,
struct fuse_file_info *fi,
function<int(FileNode *)> op) {
const function<int(FileNode *)> &op) {
EncFS_Context *ctx = context();
int res = -EIO;
@ -230,6 +230,10 @@ int encfs_readdir(const char *path, void *buf, fuse_fill_dir_t filler,
off_t offset, struct fuse_file_info *finfo) {
EncFS_Context *ctx = context();
//unused parameters
(void)offset;
(void)finfo;
int res = ESUCCESS;
std::shared_ptr<DirNode> FSRoot = ctx->getRoot(&res);
if (!FSRoot) {

View File

@ -557,8 +557,6 @@ void *encfs_init(fuse_conn_info *conn) {
return (void *)ctx;
}
void encfs_destroy(void *_ctx) {}
int main(int argc, char *argv[]) {
#if defined(ENABLE_NLS) && defined(LOCALEDIR)
setlocale(LC_ALL, "");
@ -622,7 +620,6 @@ int main(int argc, char *argv[]) {
// encfs_oper.releasedir = encfs_releasedir;
// encfs_oper.fsyncdir = encfs_fsyncdir;
encfs_oper.init = encfs_init;
encfs_oper.destroy = encfs_destroy;
// encfs_oper.access = encfs_access;
encfs_oper.create = encfs_create;
encfs_oper.ftruncate = encfs_ftruncate;

View File

@ -116,8 +116,9 @@ restart:
term.c_lflag &= ~(ECHO | ECHONL);
}
#ifdef VSTATUS
if (term.c_cc[VSTATUS] != _POSIX_VDISABLE)
if (term.c_cc[VSTATUS] != _POSIX_VDISABLE) {
term.c_cc[VSTATUS] = _POSIX_VDISABLE;
}
#endif
(void)tcsetattr(input, _T_FLUSH, &term);
} else {