allow no end of line on last line of PEMs

This commit is contained in:
toddouska 2012-11-20 12:45:24 -08:00
parent d4035e5f62
commit da386691a1
2 changed files with 11 additions and 9 deletions

View File

@ -123,7 +123,6 @@ int pbkdf2_test(void);
int ecc_test(void); int ecc_test(void);
#endif #endif
int PemToDer(const char* inName, const char* outName);
static void err_sys(const char* msg, int es) static void err_sys(const char* msg, int es)

View File

@ -895,6 +895,7 @@ int AddCA(CYASSL_CERT_MANAGER* cm, buffer der, int type, int verify)
char* headerEnd; char* headerEnd;
char* footerEnd; char* footerEnd;
char* consumedEnd; char* consumedEnd;
char* bufferEnd = (char*)(buff + longSz);
long neededSz; long neededSz;
int pkcs8 = 0; int pkcs8 = 0;
int pkcs8Enc = 0; int pkcs8Enc = 0;
@ -965,7 +966,7 @@ int AddCA(CYASSL_CERT_MANAGER* cm, buffer der, int type, int verify)
} }
headerEnd += XSTRLEN(header); headerEnd += XSTRLEN(header);
/* get next line */ /* eat end of line */
if (headerEnd[0] == '\n') if (headerEnd[0] == '\n')
headerEnd++; headerEnd++;
else if (headerEnd[1] == '\n') else if (headerEnd[1] == '\n')
@ -1023,13 +1024,15 @@ int AddCA(CYASSL_CERT_MANAGER* cm, buffer der, int type, int verify)
consumedEnd = footerEnd + XSTRLEN(footer); consumedEnd = footerEnd + XSTRLEN(footer);
/* get next line */ if (consumedEnd < bufferEnd) { /* handle no end of line on last line */
/* eat end of line */
if (consumedEnd[0] == '\n') if (consumedEnd[0] == '\n')
consumedEnd++; consumedEnd++;
else if (consumedEnd[1] == '\n') else if (consumedEnd[1] == '\n')
consumedEnd += 2; consumedEnd += 2;
else else
return SSL_BAD_FILE; return SSL_BAD_FILE;
}
if (info) if (info)
info->consumed = (long)(consumedEnd - (char*)buff); info->consumed = (long)(consumedEnd - (char*)buff);