mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-06-29 02:07:39 +08:00
cLib: Forward openssl errors properly
This commit is contained in:
@ -2,10 +2,12 @@
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <errno.h>
|
||||
#include <git2.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <git2.h>
|
||||
#include <openssl/err.h>
|
||||
|
||||
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;
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -148,5 +148,7 @@ cleanup:
|
||||
RSA_free(rsa);
|
||||
BN_free(bne);
|
||||
|
||||
return (ret == 1);
|
||||
if (ret != 1)
|
||||
return GJ_ERR_OPENSSL;
|
||||
return 0;
|
||||
}
|
||||
|
Reference in New Issue
Block a user