diff --git a/gj_common/common.c b/gj_common/common.c index a9e9dc9d..12d8721e 100644 --- a/gj_common/common.c +++ b/gj_common/common.c @@ -2,10 +2,12 @@ #include #include -#include #include #include +#include +#include + void gj_log_internal(const char *format, ...) { char buffer[1024]; @@ -23,7 +25,7 @@ gj_error *gj_error_info(int err) gj_error *error = (gj_error *)malloc(sizeof(gj_error)); error->message_allocated = false; - if (err >= GJ_ERR_FIRST && err <= GJ_ERR_LAST) + if (err <= GJ_ERR_FIRST && err >= GJ_ERR_LAST) { switch (err) { @@ -36,6 +38,13 @@ gj_error *gj_error_info(int err) error->code = err; error->message = "GitPull Invalid State"; break; + + case GJ_ERR_OPENSSL: + error->code = ERR_peek_last_error(); + error->message_allocated = true; + error->message = (char *)malloc(256); + ERR_error_string(error->code, error->message); + break; } return error; } diff --git a/gj_common/gitjournal.h b/gj_common/gitjournal.h index 8b8e9216..44cd8f9c 100644 --- a/gj_common/gitjournal.h +++ b/gj_common/gitjournal.h @@ -41,6 +41,7 @@ int gj_generate_ssh_keys(const char *private_key_path, #define GJ_ERR_FIRST -954 #define GJ_ERR_EMPTY_COMMIT -954 #define GJ_ERR_PULL_INVALID_STATE -955 -#define GJ_ERR_LAST -955 +#define GJ_ERR_OPENSSL -956 +#define GJ_ERR_LAST -956 #endif diff --git a/gj_common/keygen.c b/gj_common/keygen.c index f8f119b5..03bb2913 100644 --- a/gj_common/keygen.c +++ b/gj_common/keygen.c @@ -148,5 +148,7 @@ cleanup: RSA_free(rsa); BN_free(bne); - return (ret == 1); + if (ret != 1) + return GJ_ERR_OPENSSL; + return 0; }