aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/src
diff options
context:
space:
mode:
authorEgor Tensin <Egor.Tensin@gmail.com>2016-06-21 19:51:34 +0300
committerEgor Tensin <Egor.Tensin@gmail.com>2016-06-21 19:51:34 +0300
commitbe612cbab27967afcc60175ce78ea88b7108659e (patch)
treeb7715ddd869bb14e4492e4b0fafadc52886da7de /src
parentREADME updates (diff)
downloadaes-tools-be612cbab27967afcc60175ce78ea88b7108659e.tar.gz
aes-tools-be612cbab27967afcc60175ce78ea88b7108659e.zip
fix GCC errors
Diffstat (limited to '')
-rw-r--r--src/box.c6
-rw-r--r--src/error.c47
2 files changed, 44 insertions, 9 deletions
diff --git a/src/box.c b/src/box.c
index ca5479e..6ba833d 100644
--- a/src/box.c
+++ b/src/box.c
@@ -429,7 +429,8 @@ AES_StatusCode aes_box_encrypt_buffer(
box, src, dest, err_details)))
return status;
- (char*) src += block_size, (char*) dest += block_size;
+ src = (char*) src + block_size;
+ dest = (char*) dest + block_size;
}
if (padding_size == 0)
@@ -596,7 +597,8 @@ AES_StatusCode aes_box_decrypt_buffer(
box, src, dest, err_details)))
return status;
- (char*) src += block_size, (char*) dest += block_size;
+ src = (char*) src + block_size;
+ dest = (char*) dest + block_size;
}
if (max_padding_size == 0)
diff --git a/src/error.c b/src/error.c
index 15b2aeb..d5dec0b 100644
--- a/src/error.c
+++ b/src/error.c
@@ -13,6 +13,38 @@
#include <stdlib.h>
#include <string.h>
+#if defined(_MSC_VER) && _MSC_VER < 1900
+
+#include <stdarg.h>
+
+#define snprintf c99_snprintf
+#define vsnprintf c99_vsnprintf
+
+__inline int c99_vsnprintf(char *dest, size_t dest_size, const char *fmt, va_list ap)
+{
+ int dest_len = -1;
+
+ if (dest_size != 0)
+ dest_len = _vsnprintf_s(dest, dest_size, _TRUNCATE, fmt, ap);
+ if (dest_len == -1)
+ dest_len = _vscprintf(fmt, ap);
+
+ return dest_len;
+}
+
+__inline int c99_snprintf(char *dest, size_t dest_size, const char *fmt, ...)
+{
+ va_list ap;
+ va_start(ap, fmt);
+
+ int dest_len = c99_vsnprintf(dest, dest_size, fmt, ap);
+
+ va_end(ap);
+ return dest_len;
+}
+
+#endif
+
static void aes_fill_string(char* dest, size_t dest_size, const char* src)
{
strncpy(dest, src, dest_size);
@@ -59,9 +91,9 @@ static size_t aes_format_null_argument_error(
const char* const param_name = err_details->params.null_arg.param_name;
if (dest == NULL && dest_size == 0)
- return _snprintf(NULL, 0, fmt, param_name) + 1;
+ return snprintf(NULL, 0, fmt, param_name) + 1;
- _snprintf(dest, dest_size, fmt, param_name);
+ snprintf(dest, dest_size, fmt, param_name);
return strlen(dest);
}
@@ -75,9 +107,9 @@ static size_t aes_format_parse_error(
const char* const what = err_details->params.parse_error.what;
if (dest == NULL)
- return _snprintf(NULL, 0, fmt, src, what) + 1;
+ return snprintf(NULL, 0, fmt, src, what) + 1;
- _snprintf(dest, dest_size, fmt, src, what);
+ snprintf(dest, dest_size, fmt, src, what);
return strlen(dest);
}
@@ -90,9 +122,9 @@ static size_t aes_format_not_implemented_error(
const char* const src = err_details->params.not_implemented.what;
if (dest == NULL)
- return _snprintf(NULL, 0, fmt, src) + 1;
+ return snprintf(NULL, 0, fmt, src) + 1;
- _snprintf(dest, dest_size, fmt, src);
+ snprintf(dest, dest_size, fmt, src);
return strlen(dest);
}
@@ -124,7 +156,8 @@ size_t aes_format_error(
static void aes_collect_call_stack(AES_ErrorDetails* err_details)
{
- err_details->call_stack_size = CaptureStackBackTrace(1, AES_MAX_CALL_STACK_LENGTH, err_details->call_stack, NULL);
+ err_details->call_stack_size = CaptureStackBackTrace(
+ 1, AES_MAX_CALL_STACK_LENGTH, err_details->call_stack, NULL);
}
#else
static void aes_collect_call_stack(AES_ErrorDetails* err_details)