mirror of
https://github.com/GitJournal/GitJournal.git
synced 2025-06-29 10:17:16 +08:00
cLib: Forward openssl errors properly
This commit is contained in:
@ -2,10 +2,12 @@
|
|||||||
|
|
||||||
#include <stdarg.h>
|
#include <stdarg.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <git2.h>
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
|
#include <git2.h>
|
||||||
|
#include <openssl/err.h>
|
||||||
|
|
||||||
void gj_log_internal(const char *format, ...)
|
void gj_log_internal(const char *format, ...)
|
||||||
{
|
{
|
||||||
char buffer[1024];
|
char buffer[1024];
|
||||||
@ -23,7 +25,7 @@ gj_error *gj_error_info(int err)
|
|||||||
|
|
||||||
gj_error *error = (gj_error *)malloc(sizeof(gj_error));
|
gj_error *error = (gj_error *)malloc(sizeof(gj_error));
|
||||||
error->message_allocated = false;
|
error->message_allocated = false;
|
||||||
if (err >= GJ_ERR_FIRST && err <= GJ_ERR_LAST)
|
if (err <= GJ_ERR_FIRST && err >= GJ_ERR_LAST)
|
||||||
{
|
{
|
||||||
switch (err)
|
switch (err)
|
||||||
{
|
{
|
||||||
@ -36,6 +38,13 @@ gj_error *gj_error_info(int err)
|
|||||||
error->code = err;
|
error->code = err;
|
||||||
error->message = "GitPull Invalid State";
|
error->message = "GitPull Invalid State";
|
||||||
break;
|
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;
|
return error;
|
||||||
}
|
}
|
||||||
|
@ -41,6 +41,7 @@ int gj_generate_ssh_keys(const char *private_key_path,
|
|||||||
#define GJ_ERR_FIRST -954
|
#define GJ_ERR_FIRST -954
|
||||||
#define GJ_ERR_EMPTY_COMMIT -954
|
#define GJ_ERR_EMPTY_COMMIT -954
|
||||||
#define GJ_ERR_PULL_INVALID_STATE -955
|
#define GJ_ERR_PULL_INVALID_STATE -955
|
||||||
#define GJ_ERR_LAST -955
|
#define GJ_ERR_OPENSSL -956
|
||||||
|
#define GJ_ERR_LAST -956
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -148,5 +148,7 @@ cleanup:
|
|||||||
RSA_free(rsa);
|
RSA_free(rsa);
|
||||||
BN_free(bne);
|
BN_free(bne);
|
||||||
|
|
||||||
return (ret == 1);
|
if (ret != 1)
|
||||||
|
return GJ_ERR_OPENSSL;
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user