summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNikos Mavrogiannopoulos <nmav@gnutls.org>2010-09-10 15:25:47 +0200
committerNikos Mavrogiannopoulos <nmav@gnutls.org>2010-09-10 15:25:47 +0200
commit7bb63d397b09df84e324b65117dc27e254512462 (patch)
treeb9e14531edf9cd9e4710a28e946d26b53009a178
parent3774e819df961ce146526d9c9e688ff0f62e0987 (diff)
downloadgnutls-7bb63d397b09df84e324b65117dc27e254512462.tar.gz
Be liberal in the PEM decoding. That is spaces and tabs are being skipped.
-rw-r--r--lib/x509_b64.c12
1 files changed, 4 insertions, 8 deletions
diff --git a/lib/x509_b64.c b/lib/x509_b64.c
index 767dbd8933..c9bea304db 100644
--- a/lib/x509_b64.c
+++ b/lib/x509_b64.c
@@ -414,7 +414,7 @@ cpydata (const uint8_t * data, int data_size, uint8_t ** result)
for (j = i = 0; i < data_size; i++)
{
- if (data[i] == '\n' || data[i] == '\r')
+ if (data[i] == '\n' || data[i] == '\r' || data[i] == ' ' || data[i] == '\t')
continue;
(*result)[j] = data[i];
j++;
@@ -427,15 +427,14 @@ cpydata (const uint8_t * data, int data_size, uint8_t ** result)
*
* The result_size is the return value
*/
-#define ENDSTR "-----\n"
-#define ENDSTR2 "-----\r"
+#define ENDSTR "-----"
int
_gnutls_fbase64_decode (const char *header, const opaque * data,
size_t data_size, uint8_t ** result)
{
int ret;
static const char top[] = "-----BEGIN ";
- static const char bottom[] = "\n-----END ";
+ static const char bottom[] = "-----END ";
uint8_t *rdata;
int rdata_size;
uint8_t *kdata;
@@ -463,13 +462,10 @@ _gnutls_fbase64_decode (const char *header, const opaque * data,
return GNUTLS_E_BASE64_DECODING_ERROR;
}
- kdata = memmem (rdata, data_size, ENDSTR, sizeof (ENDSTR) - 1);
+ kdata = memmem (rdata+1, data_size-1, ENDSTR, sizeof (ENDSTR) - 1);
/* allow CR as well.
*/
if (kdata == NULL)
- kdata = memmem (rdata, data_size, ENDSTR2, sizeof (ENDSTR2) - 1);
-
- if (kdata == NULL)
{
gnutls_assert ();
_gnutls_x509_log ("Could not find '%s'\n", ENDSTR);