Remove dependency on strndupa

Actually only glibc seems to implement this
This commit is contained in:
j.r 2022-03-24 14:17:17 +01:00
parent e6932aa951
commit a69ec72615
No known key found for this signature in database
GPG Key ID: E74A18B933F9145E

View File

@ -175,7 +175,9 @@ char* _pgp_encrypt_message(xmppc_t *xmppc, char* recipient, char* message) {
} }
static char* _pgp_remove_PGP_MESSAGE_comment(const char* message) { static char* _pgp_remove_PGP_MESSAGE_comment(const char* message) {
char* tmp = strndupa(message, strlen(message) - (strlen(PGP_END)+1)); char* tmp = alloca((strlen(message) - strlen(PGP_END)) + 1);
strncpy(tmp, message, strlen(message) - strlen(PGP_END));
tmp[(strlen(message) - strlen(PGP_END)+1)] = '\0';
tmp = tmp+((strlen(PGP_BEGIN) +1) * sizeof(char)); tmp = tmp+((strlen(PGP_BEGIN) +1) * sizeof(char));
char* result = malloc(strlen(tmp)+1); char* result = malloc(strlen(tmp)+1);
strcpy(result, tmp); strcpy(result, tmp);