1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2025-03-24 06:50:08 +03:00

io: Fix compressed flag for uncompressed stdin

This could cause xmlstarlet to generate compressed output unexpectedly.

Regressed with a78843be. Should fix #869.
This commit is contained in:
Nick Wellnhofer 2025-03-02 13:21:29 +01:00
parent 05bd1720ce
commit a0f156fffb

12
xmlIO.c
View File

@ -1060,7 +1060,9 @@ xmlInputFromFd(xmlParserInputBufferPtr buf, int fd, int flags) {
if (xzStream == NULL) {
close(copy);
} else {
if ((__libxml2_xzcompressed(xzStream) > 0) ||
int compressed = (__libxml2_xzcompressed(xzStream) > 0);
if ((compressed) ||
/* Try to rewind if not gzip compressed */
(pos < 0) ||
(lseek(fd, pos, SEEK_SET) < 0)) {
@ -1071,7 +1073,7 @@ xmlInputFromFd(xmlParserInputBufferPtr buf, int fd, int flags) {
buf->context = xzStream;
buf->readcallback = xmlXzfileRead;
buf->closecallback = xmlXzfileClose;
buf->compressed = 1;
buf->compressed = compressed;
return(XML_ERR_OK);
}
@ -1097,7 +1099,9 @@ xmlInputFromFd(xmlParserInputBufferPtr buf, int fd, int flags) {
if (gzStream == NULL) {
close(copy);
} else {
if ((gzdirect(gzStream) == 0) ||
int compressed = (gzdirect(gzStream) == 0);
if ((compressed) ||
/* Try to rewind if not gzip compressed */
(pos < 0) ||
(lseek(fd, pos, SEEK_SET) < 0)) {
@ -1108,7 +1112,7 @@ xmlInputFromFd(xmlParserInputBufferPtr buf, int fd, int flags) {
buf->context = gzStream;
buf->readcallback = xmlGzfileRead;
buf->closecallback = xmlGzfileClose;
buf->compressed = 1;
buf->compressed = compressed;
return(XML_ERR_OK);
}