Skip to content

Commit

Permalink
(xmlsec-core) Replace old LibXML2 functions with newer versions (#785)
Browse files Browse the repository at this point in the history
  • Loading branch information
lsh123 authored May 4, 2024
1 parent d12e5db commit c4fb6ae
Show file tree
Hide file tree
Showing 15 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion examples/decrypt1.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ decrypt_file(const char* enc_file, const char* key_file) {
assert(key_file);

/* load template */
doc = xmlParseFile(enc_file);
doc = xmlReadFile(enc_file, NULL, XML_PARSE_PEDANTIC | XML_PARSE_NONET);
if ((doc == NULL) || (xmlDocGetRootElement(doc) == NULL)){
fprintf(stderr, "Error: unable to parse file \"%s\"\n", enc_file);
goto done;
Expand Down
2 changes: 1 addition & 1 deletion examples/decrypt2.c
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ decrypt_file(xmlSecKeysMngrPtr mngr, const char* enc_file) {
assert(enc_file);

/* load template */
doc = xmlParseFile(enc_file);
doc = xmlReadFile(enc_file, NULL, XML_PARSE_PEDANTIC | XML_PARSE_NONET);
if ((doc == NULL) || (xmlDocGetRootElement(doc) == NULL)){
fprintf(stderr, "Error: unable to parse file \"%s\"\n", enc_file);
goto done;
Expand Down
2 changes: 1 addition & 1 deletion examples/decrypt3.c
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ decrypt_file(xmlSecKeysMngrPtr mngr, const char* enc_file) {
assert(enc_file);

/* load template */
doc = xmlParseFile(enc_file);
doc = xmlReadFile(enc_file, NULL, XML_PARSE_PEDANTIC | XML_PARSE_NONET);
if ((doc == NULL) || (xmlDocGetRootElement(doc) == NULL)){
fprintf(stderr, "Error: unable to parse file \"%s\"\n", enc_file);
goto done;
Expand Down
2 changes: 1 addition & 1 deletion examples/encrypt1.c
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ encrypt_file(const char* tmpl_file, const char* key_file,
assert(data);

/* load template */
doc = xmlParseFile(tmpl_file);
doc = xmlReadFile(tmpl_file, NULL, XML_PARSE_PEDANTIC | XML_PARSE_NONET);
if ((doc == NULL) || (xmlDocGetRootElement(doc) == NULL)){
fprintf(stderr, "Error: unable to parse file \"%s\"\n", tmpl_file);
goto done;
Expand Down
2 changes: 1 addition & 1 deletion examples/encrypt2.c
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ encrypt_file(const char* xml_file, const char* key_file) {
assert(key_file);

/* load template */
doc = xmlParseFile(xml_file);
doc = xmlReadFile(xml_file, NULL, XML_PARSE_PEDANTIC | XML_PARSE_NONET);
if ((doc == NULL) || (xmlDocGetRootElement(doc) == NULL)){
fprintf(stderr, "Error: unable to parse file \"%s\"\n", xml_file);
goto done;
Expand Down
2 changes: 1 addition & 1 deletion examples/encrypt3.c
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ encrypt_file(xmlSecKeysMngrPtr mngr, const char* xml_file, const char* key_name)
assert(key_name);

/* load template */
doc = xmlParseFile(xml_file);
doc = xmlReadFile(xml_file, NULL, XML_PARSE_PEDANTIC | XML_PARSE_NONET);
if ((doc == NULL) || (xmlDocGetRootElement(doc) == NULL)){
fprintf(stderr, "Error: unable to parse file \"%s\"\n", xml_file);
goto done;
Expand Down
2 changes: 1 addition & 1 deletion examples/sign1.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ sign_file(const char* tmpl_file, const char* key_file) {
assert(key_file);

/* load template */
doc = xmlParseFile(tmpl_file);
doc = xmlReadFile(tmpl_file, NULL, XML_PARSE_PEDANTIC | XML_PARSE_NONET);
if ((doc == NULL) || (xmlDocGetRootElement(doc) == NULL)){
fprintf(stderr, "Error: unable to parse file \"%s\"\n", tmpl_file);
goto done;
Expand Down
2 changes: 1 addition & 1 deletion examples/sign2.c
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ sign_file(const char* xml_file, const char* key_file) {
assert(key_file);

/* load doc file */
doc = xmlParseFile(xml_file);
doc = xmlReadFile(xml_file, NULL, XML_PARSE_PEDANTIC | XML_PARSE_NONET);
if ((doc == NULL) || (xmlDocGetRootElement(doc) == NULL)){
fprintf(stderr, "Error: unable to parse file \"%s\"\n", xml_file);
goto done;
Expand Down
2 changes: 1 addition & 1 deletion examples/sign3.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ sign_file(const char* xml_file, const char* key_file, const char* cert_file) {
assert(cert_file);

/* load doc file */
doc = xmlParseFile(xml_file);
doc = xmlReadFile(xml_file, NULL, XML_PARSE_PEDANTIC | XML_PARSE_NONET);
if ((doc == NULL) || (xmlDocGetRootElement(doc) == NULL)){
fprintf(stderr, "Error: unable to parse file \"%s\"\n", xml_file);
goto done;
Expand Down
2 changes: 1 addition & 1 deletion examples/verify1.c
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ verify_file(const char* xml_file, const char* key_file) {
assert(key_file);

/* load file */
doc = xmlParseFile(xml_file);
doc = xmlReadFile(xml_file, NULL, XML_PARSE_PEDANTIC | XML_PARSE_NONET);
if ((doc == NULL) || (xmlDocGetRootElement(doc) == NULL)){
fprintf(stderr, "Error: unable to parse file \"%s\"\n", xml_file);
goto done;
Expand Down
2 changes: 1 addition & 1 deletion examples/verify2.c
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ verify_file(xmlSecKeysMngrPtr mngr, const char* xml_file) {
assert(xml_file);

/* load file */
doc = xmlParseFile(xml_file);
doc = xmlReadFile(xml_file, NULL, XML_PARSE_PEDANTIC | XML_PARSE_NONET);
if ((doc == NULL) || (xmlDocGetRootElement(doc) == NULL)){
fprintf(stderr, "Error: unable to parse file \"%s\"\n", xml_file);
goto done;
Expand Down
2 changes: 1 addition & 1 deletion examples/verify3.c
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ verify_file(xmlSecKeysMngrPtr mngr, const char* xml_file) {
assert(xml_file);

/* load file */
doc = xmlParseFile(xml_file);
doc = xmlReadFile(xml_file, NULL, XML_PARSE_PEDANTIC | XML_PARSE_NONET);
if ((doc == NULL) || (xmlDocGetRootElement(doc) == NULL)){
fprintf(stderr, "Error: unable to parse file \"%s\"\n", xml_file);
goto done;
Expand Down
2 changes: 1 addition & 1 deletion examples/verify4.c
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ verify_file(xmlSecKeysMngrPtr mngr, const char* xml_file) {
assert(xml_file);

/* load file */
doc = xmlParseFile(xml_file);
doc = xmlReadFile(xml_file, NULL, XML_PARSE_PEDANTIC | XML_PARSE_NONET);
if ((doc == NULL) || (xmlDocGetRootElement(doc) == NULL)){
fprintf(stderr, "Error: unable to parse file \"%s\"\n", xml_file);
goto done;
Expand Down
4 changes: 2 additions & 2 deletions src/keysmngr.c
Original file line number Diff line number Diff line change
Expand Up @@ -503,9 +503,9 @@ xmlSecSimpleKeysStoreLoad_ex(xmlSecKeyStorePtr store, const char *uri,
xmlSecAssert2(adoptKeyFunc != NULL, -1);
UNREFERENCED_PARAMETER(keysMngr);

doc = xmlParseFile(uri);
doc = xmlReadFile(uri, NULL, XML_PARSE_PEDANTIC | XML_PARSE_NONET);
if(doc == NULL) {
xmlSecXmlError2("xmlParseFile", xmlSecKeyStoreGetName(store),
xmlSecXmlError2("xmlReadFile ", xmlSecKeyStoreGetName(store),
"uri=%s", xmlSecErrorsSafeString(uri));
return(-1);
}
Expand Down
4 changes: 2 additions & 2 deletions src/templates.c
Original file line number Diff line number Diff line change
Expand Up @@ -1569,9 +1569,9 @@ xmlSecTmplTransformAddXsltStylesheet(xmlNodePtr transformNode, const xmlChar *xs
xmlSecAssert2(transformNode != NULL, -1);
xmlSecAssert2(xslt != NULL, -1);

xsltDoc = xmlParseMemory((const char*)xslt, xmlStrlen(xslt));
xsltDoc = xmlReadMemory((const char*)xslt, xmlStrlen(xslt), NULL, NULL, XML_PARSE_PEDANTIC | XML_PARSE_NONET);
if(xsltDoc == NULL) {
xmlSecXmlError("xmlParseMemory", NULL);
xmlSecXmlError("xmlReadMemory", NULL);
return(-1);
}

Expand Down

0 comments on commit c4fb6ae

Please sign in to comment.