libsec: allow \r\n terminated lines in decodePEM()

This commit is contained in:
cinap_lenrek 2017-10-05 20:33:46 +02:00
parent 99700fb024
commit 5f42da1535

View file

@ -25,13 +25,15 @@ decodePEM(char *s, char *type, int *len, char **new_s)
t++; t++;
if(strncmp(tt, "-----BEGIN ", STRLEN("-----BEGIN ")) == 0 if(strncmp(tt, "-----BEGIN ", STRLEN("-----BEGIN ")) == 0
&& strncmp(&tt[STRLEN("-----BEGIN ")], type, n) == 0 && strncmp(&tt[STRLEN("-----BEGIN ")], type, n) == 0
&& strncmp(&tt[STRLEN("-----BEGIN ")+n], "-----\n", STRLEN("-----\n")) == 0) && strncmp(&tt[STRLEN("-----BEGIN ")+n], "-----", STRLEN("-----")) == 0
&& strchr("\r\n", tt[STRLEN("-----BEGIN ")+n+STRLEN("-----")]) != nil)
break; break;
} }
for(tt = t; tt != nil && tt < e; tt++){ for(tt = t; tt != nil && tt < e; tt++){
if(strncmp(tt, "-----END ", STRLEN("-----END ")) == 0 if(strncmp(tt, "-----END ", STRLEN("-----END ")) == 0
&& strncmp(&tt[STRLEN("-----END ")], type, n) == 0 && strncmp(&tt[STRLEN("-----END ")], type, n) == 0
&& strncmp(&tt[STRLEN("-----END ")+n], "-----\n", STRLEN("-----\n")) == 0) && strncmp(&tt[STRLEN("-----END ")+n], "-----", STRLEN("-----")) == 0
&& strchr("\r\n", tt[STRLEN("-----END ")+n+STRLEN("-----")]) != nil)
break; break;
tt = strchr(tt, '\n'); tt = strchr(tt, '\n');
if(tt == nil) if(tt == nil)