From borucki.andrzej@gmail.com Thu Oct 15 13:00:41 2020 Return-Path: X-Original-To: xml@gnome.org Delivered-To: xml@gnome.org Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp.gnome.org (Postfix) with ESMTP id C5115A02D3 for ; Thu, 15 Oct 2020 13:00:41 +0000 (UTC) X-Virus-Scanned: by amavisd-new at gnome.org X-Spam-Flag: NO X-Spam-Score: -0.599 X-Spam-Level: X-Spam-Status: No, score=-0.599 tagged_above=-999 required=6.2 tests=[BAYES_00=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, FREEMAIL_FROM=0.5, HTML_MESSAGE=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=no autolearn_force=no Received: from smtp.gnome.org ([127.0.0.1]) by localhost (restaurant.gnome.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id bgRMpHwJw0MZ for ; Thu, 15 Oct 2020 13:00:39 +0000 (UTC) Received: from mail-qv1-xf41.google.com (mail-qv1-xf41.google.com [IPv6:2607:f8b0:4864:20::f41]) by smtp.gnome.org (Postfix) with ESMTPS id D4514A02C0 for ; Thu, 15 Oct 2020 13:00:39 +0000 (UTC) Received: by mail-qv1-xf41.google.com with SMTP id b10so1119407qvf.0 for ; Thu, 15 Oct 2020 06:00:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=JDY33ufoVyFJJwcEl/lu40MI+97oRvbLjAmRgNT6jB0=; b=U72bQWlkvgstY/0wea/le8odnQpN1Aqz+WnfedWFBlIpQo+sWRwR87+D7seMLurgRM uCQYaIejc+uxe+UgXX5FJ7bj7xCX4hAftRpPJ2pLrH8Fydkv6ayUwW6HpOY/1QagjufS 2yDuVeN4ROJ94jERG1BF06ILbv83SD9BpoVxA+aYxzWpSewj5Lybfm7xvvDjU6byzr13 iPzGusqgTzvvM5R7+R+2ytRZNLNTMDDODTelXf5GgJyqUAHgDlRR1cCqQcP9M5x3gF63 iC10L874e1e899qRsiRKrOCQjN8Mtx6/QT7SNhJwBlm7q5ZBzbYdaAV24kn005l3Y4Kn pyew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=JDY33ufoVyFJJwcEl/lu40MI+97oRvbLjAmRgNT6jB0=; b=fP2GTu3EwL+zK3OwdgP6eP3JhtThDAozO77Gn7+vCb3mOjfP15UhykA2fzs1rry3qW Cn4jnI4clY42o14dv+kVP6cdhG/0Uwdm81smBoOclM+7gHOj1XECaSg14/jHPxvg4mb4 oE87GBpNhMpBU9N1N1VSJeiLurXsT3hyifmUqnDFvjuYdY0vRdFnL21jLPDeaeTfKUFo 3RhfDXx7IqQwFrPK9SuTWfKfbf/FsloWBKom7ApR8EgpQ6jB1+Czv3GqdNUCd2zZ1FcF 66e4IPJ50ijuKNyt/TkMW+VgW5X73oqYH3vc3nZnJ1/88r93TswuHwjsRnjvDyCPYFhj vSlg== X-Gm-Message-State: AOAM530z6YxklVJJOiOgFql2ORQvvQJDf36Nd8jZEXD7Qw7wLyoVjaaG JxvdmqeFEYMfE3WYHAB+NDZVgNLzhcO/qYfyILHcdmYteuvEWg== X-Google-Smtp-Source: ABdhPJyJlzR8WYYd969UDIh14unMRjEktSHXOJSCCXkJG6/XF/E8qpAC1zybqwbigZeh8MIJk886ATlRQ8ruFN7TuqA= X-Received: by 2002:a0c:bec4:: with SMTP id f4mr4682373qvj.14.1602766838070; Thu, 15 Oct 2020 06:00:38 -0700 (PDT) MIME-Version: 1.0 From: Andy Date: Thu, 15 Oct 2020 15:00:26 +0200 Message-ID: To: xml@gnome.org Content-Type: multipart/alternative; boundary="0000000000000a809b05b1b53c52" Subject: [xml] How libxml2 can preserve spaces? X-BeenThere: xml@gnome.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: The Gnome XML library mailing-list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 15 Oct 2020 13:00:41 -0000 --0000000000000a809b05b1b53c52 Content-Type: text/plain; charset="UTF-8" Wiktionary xml need space preserving, small example xml: Template:All messages 10 570 2754 This is a list of all messages available in the MediaWiki: namespace <table border=1 width=100%><tr><td> '''Name''' </td><td> I am using libxml2 with wrapper libxml++ and use example from https://github.com/libxmlplusplus/libxmlplusplus/tree/libxml++-3-2/examples/sax_parser In method MySaxParser::on_characters I give new line characters after chars < and > --0000000000000a809b05b1b53c52 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Wiktionary xml need space preserving, small example x= ml:
<=
code><mediawiki xmlns=3D"http://www.mediawiki.org/xml=
/export-0.10/" xmlns:xsi=3D"http://www.w3=
.org/2001/XMLSchema-instance" xsi:schemaLocation=3D"http://www.mediawiki.org/xml/export-0.10/ http://www.mediawiki.org/xml/export-=
0.10.xsd" version=3D"=
;0.10" xml:lang=3D"iu&qu=
ot;>
  <page>
    <title>Template:All messages</title>
    <ns>10</ns>
    <id>570</id>
    <revision>
      <id>2754</id>
      <text bytes=3D"127367"=
 xml:space=3D"preserve"<=
/span>>This is a list of all =
messages available in the MediaWiki: nam=
espace
&lt;table border=3D1 width=3D<=
span class=3D"gmail-hljs-number">100%&gt;&lt;tr&gt;&=
lt;td&gt;
  '''Name'''
&lt;/td&gt;&lt;td&gt;
        </text>
    </revision>
  </page>
</mediawiki>

I am using libxml2 with wrapper libxml++ and =
use example from 
https://github.com/libxmlplusp= lus/libxmlplusplus/tree/libxml++-3-2/examples/sax_parser
In meth=
od MySaxParser::on_characters I give new line characters after  chars < =
and >


--0000000000000a809b05b1b53c52-- From rjones@redhat.com Sat Oct 17 10:24:42 2020 Return-Path: X-Original-To: xml@gnome.org Delivered-To: xml@gnome.org Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp.gnome.org (Postfix) with ESMTP id A379BA02FC for ; Sat, 17 Oct 2020 10:24:42 +0000 (UTC) X-Virus-Scanned: by amavisd-new at gnome.org X-Spam-Flag: NO X-Spam-Score: -1.099 X-Spam-Level: X-Spam-Status: No, score=-1.099 tagged_above=-999 required=6.2 tests=[BAYES_00=-1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H5=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=no autolearn_force=no Received: from smtp.gnome.org ([127.0.0.1]) by localhost (restaurant.gnome.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id bzMcXr-y3mvF for ; Sat, 17 Oct 2020 10:24:41 +0000 (UTC) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by smtp.gnome.org (Postfix) with ESMTPS id CDF81A02FB for ; Sat, 17 Oct 2020 10:24:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1602930280; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type; bh=garUJrqe8WKfaQOQBUBSOQ69cmUR5Badci4otdbC7yw=; b=E6n3O12+LkG1T3Rew4w4H7rXSHm9V2FW4Rs3s8xsDnweT19yl/GY0gJVeZG/DdluiMkNAQ C8jv2E2YBKvwA2PSPEr4NdJlNTJo8ptNS2HRFdYVarQzjq9wwu5aDW80ESgggAZkwKjZi2 f2VT2ad8G2XNQ7hYoYryCosF9xQ2Y+Q= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-22-Joz6YcxoNBuxr4wfWI-EQQ-1; Sat, 17 Oct 2020 06:24:36 -0400 X-MC-Unique: Joz6YcxoNBuxr4wfWI-EQQ-1 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7CFFF186841A for ; Sat, 17 Oct 2020 10:24:35 +0000 (UTC) Received: from localhost (ovpn-114-98.ams2.redhat.com [10.36.114.98]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5FCD05D9CC; Sat, 17 Oct 2020 10:24:32 +0000 (UTC) Date: Sat, 17 Oct 2020 11:24:31 +0100 From: "Richard W.M. Jones" To: xml@gnome.org, libguestfs@redhat.com Cc: Eric Blake , Stefano Garzarella Message-ID: <20201017102431.GA9756@redhat.com> MIME-Version: 1.0 User-Agent: Mutt/1.5.21 (2010-09-15) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=rjones@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Subject: [xml] Why does libxml2 limit port numbers to 999,999,999? X-BeenThere: xml@gnome.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: The Gnome XML library mailing-list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 17 Oct 2020 10:24:42 -0000 The AF_VSOCK protocol added in Linux 5.6 uses a 32 bit port number. For NBD we map this to simple URIs[1] like nbd+vsock://CID:PORT (where CID is a number that acts a bit like a hostname and PORT is a 32 bit port number). eg: nbd+vsock://1:1000000000/ would be port 10^9 on the loopback address VMADDR_CID_LOCAL (== 1). The problem is that libxml2 arbitrarily limits port numbers to 999,999,999. I don't see any support for this limit in RFC 3986 [2]. Here is the code: https://github.com/GNOME/libxml2/blob/46837d47d59c7b8c9bd1d08a6a717a90a7f1ceb6/uri.c#L333 It doesn't even return an error, just truncates the port number. You can see the problem with the program [3] below. It seems like libxml2 chose to do this for convenience rather than correctness. I think it should accept port numbers at least up to signed int (the type used to store port numbers), and give an error if the port number overflows. Is there anything I'm missing or would a patch which implements that be acceptable? Also could the uri->port field be changed to unsigned int without breaking ABI? Rich. [1] https://github.com/NetworkBlockDevice/nbd/blob/master/doc/uri.md [2] https://tools.ietf.org/html/rfc3986#section-3.2.3 [3] $ cat port.c #include #include #include #include #include int main (int argc, char *argv[]) { xmlURIPtr uri = xmlParseURI (argv[1]); if (!uri) { fprintf (stderr, "xmlParseURI failed\n"); exit (EXIT_FAILURE); } printf ("%s => uri->port = %d\n", argv[1], uri->port); exit (EXIT_SUCCESS); } $ ./port nbd+vsock://1:1000 nbd+vsock://1:1000 => uri->port = 1000 $ ./port nbd+vsock://1:100000 nbd+vsock://1:100000 => uri->port = 100000 $ ./port nbd+vsock://1:10000000 nbd+vsock://1:10000000 => uri->port = 10000000 $ ./port nbd+vsock://1:1000000000 nbd+vsock://1:1000000000 => uri->port = 99999999 -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com virt-top is 'top' for virtual machines. Tiny program with many powerful monitoring features, net stats, disk stats, logging, etc. http://people.redhat.com/~rjones/virt-top From rjones@redhat.com Sat Oct 17 10:30:09 2020 Return-Path: X-Original-To: xml@gnome.org Delivered-To: xml@gnome.org Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp.gnome.org (Postfix) with ESMTP id 6EC6DA056A for ; Sat, 17 Oct 2020 10:30:09 +0000 (UTC) X-Virus-Scanned: by amavisd-new at gnome.org X-Spam-Flag: NO X-Spam-Score: -1.099 X-Spam-Level: X-Spam-Status: No, score=-1.099 tagged_above=-999 required=6.2 tests=[BAYES_00=-1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=no autolearn_force=no Received: from smtp.gnome.org ([127.0.0.1]) by localhost (restaurant.gnome.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id LTx8c9W-fgWn for ; Sat, 17 Oct 2020 10:30:07 +0000 (UTC) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by smtp.gnome.org (Postfix) with ESMTPS id 69153A0567 for ; Sat, 17 Oct 2020 10:30:07 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1602930605; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=l4Bi3zMmb4v+1iyCGP4HUST0tSjFSCgoyoN7fRNTMlI=; b=APAAA/XEwY7g2x60TezyffMrgFJE+xIh1EGnihnW19CHpKshilkU0dovcClgmiD4mPne7S 5EyQFWcWhRICovz3f5z70gRDIOE1iJ63YmYtiskYkuQewwGti+/UYFE+55aXdnjkA9Zj3s QiZOT+vxPX8i13y82kJNNErIPR/8acI= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-175--xQHcJpCPtaL9cgc6IW6Hg-1; Sat, 17 Oct 2020 06:30:02 -0400 X-MC-Unique: -xQHcJpCPtaL9cgc6IW6Hg-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E1C94835B58 for ; Sat, 17 Oct 2020 10:30:00 +0000 (UTC) Received: from localhost (ovpn-114-98.ams2.redhat.com [10.36.114.98]) by smtp.corp.redhat.com (Postfix) with ESMTP id D0C635C1D0; Sat, 17 Oct 2020 10:29:57 +0000 (UTC) Date: Sat, 17 Oct 2020 11:29:56 +0100 From: "Richard W.M. Jones" To: xml@gnome.org, libguestfs@redhat.com, Eric Blake , Stefano Garzarella Message-ID: <20201017102956.GB9756@redhat.com> References: <20201017102431.GA9756@redhat.com> MIME-Version: 1.0 In-Reply-To: <20201017102431.GA9756@redhat.com> User-Agent: Mutt/1.5.21 (2010-09-15) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=rjones@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Subject: Re: [xml] Why does libxml2 limit port numbers to 99,999,999? X-BeenThere: xml@gnome.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: The Gnome XML library mailing-list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 17 Oct 2020 10:30:09 -0000 On Sat, Oct 17, 2020 at 11:24:31AM +0100, Richard W.M. Jones via xml wrote: > The problem is that libxml2 arbitrarily limits port numbers to > 999,999,999. I don't see any support for this limit in RFC 3986 [2]. Actually I miscounted the number of 9's. The limit is 99,999,999. The rest still applies. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com virt-builder quickly builds VMs from scratch http://libguestfs.org/virt-builder.1.html From wellnhofer@aevum.de Sat Oct 17 16:38:30 2020 Return-Path: X-Original-To: xml@gnome.org Delivered-To: xml@gnome.org Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp.gnome.org (Postfix) with ESMTP id 21383A02D3 for ; Sat, 17 Oct 2020 16:38:30 +0000 (UTC) X-Virus-Scanned: by amavisd-new at gnome.org X-Spam-Flag: NO X-Spam-Score: -1.002 X-Spam-Level: X-Spam-Status: No, score=-1.002 tagged_above=-999 required=6.2 tests=[BAYES_00=-1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001] autolearn=no autolearn_force=no Received: from smtp.gnome.org ([127.0.0.1]) by localhost (restaurant.gnome.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id nebl4r3f7D2w for ; Sat, 17 Oct 2020 16:38:29 +0000 (UTC) X-Greylist: delayed 365 seconds by postgrey-1.34 at restaurant.gnome.org; Sat, 17 Oct 2020 16:38:29 UTC Received: from hosting04.aevum.de (hosting04.aevum.de [IPv6:2a03:4000:6:f048::1]) by smtp.gnome.org (Postfix) with ESMTPS id 276C6A02C0 for ; Sat, 17 Oct 2020 16:38:29 +0000 (UTC) Received: from [IPv6:2001:a62:312:7701:115f:4df7:8f7e:1b10] (unknown [IPv6:2001:a62:312:7701:115f:4df7:8f7e:1b10]) by hosting04.aevum.de (Postfix) with ESMTPSA id E9BD4600AB; Sat, 17 Oct 2020 18:32:19 +0200 (CEST) Content-Type: text/plain; charset=utf-8 Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.17\)) From: Nick Wellnhofer In-Reply-To: <20201017102431.GA9756@redhat.com> Date: Sat, 17 Oct 2020 18:32:18 +0200 Cc: Jeffrey Walton via xml , libguestfs@redhat.com, Eric Blake , Stefano Garzarella Content-Transfer-Encoding: quoted-printable Message-Id: References: <20201017102431.GA9756@redhat.com> To: "Richard W.M. Jones" X-Mailer: Apple Mail (2.3445.104.17) Subject: Re: [xml] Why does libxml2 limit port numbers to 999,999,999? X-BeenThere: xml@gnome.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: The Gnome XML library mailing-list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 17 Oct 2020 16:38:30 -0000 On Oct 17, 2020, at 12:24 , Richard W.M. Jones via xml = wrote: > It seems like libxml2 chose to do this for convenience rather than > correctness. Yes, this is an arbitrary limit introduced to avoid integer overflow. =20 > I think it should accept port numbers at least up to > signed int (the type used to store port numbers), and give an error if > the port number overflows. This is fixed now: = https://gitlab.gnome.org/GNOME/libxml2/-/commit/b46016b8705b041c0678dd45e4= 45dc73674b75d0 > Also could the uri->port field be changed to unsigned int without > breaking ABI? It=E2=80=99s a public struct member, so strictly speaking, no. But the = risk to break stuff seems low. Nick From rjones@redhat.com Sat Oct 17 18:03:33 2020 Return-Path: X-Original-To: xml@gnome.org Delivered-To: xml@gnome.org Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp.gnome.org (Postfix) with ESMTP id E9647A02D3 for ; Sat, 17 Oct 2020 18:03:33 +0000 (UTC) X-Virus-Scanned: by amavisd-new at gnome.org X-Spam-Flag: NO X-Spam-Score: -1.099 X-Spam-Level: X-Spam-Status: No, score=-1.099 tagged_above=-999 required=6.2 tests=[BAYES_00=-1, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001] autolearn=no autolearn_force=no Received: from smtp.gnome.org ([127.0.0.1]) by localhost (restaurant.gnome.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id MQeuO_nz-h46 for ; Sat, 17 Oct 2020 18:03:33 +0000 (UTC) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by smtp.gnome.org (Postfix) with ESMTPS id 79057A02CA for ; Sat, 17 Oct 2020 18:03:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1602957812; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=sWEK3TmXEoo/qLwoMVUy7/d+bhr1u1rN3iAYaG8Fq+Y=; b=KcrAJ6/X8Im8U2TZSV1ZpTRhgyWoo2ZOy9N0WBp6m9eAcyeicIyBURQzPEUYBhIWW5mNRH hJvXMuz3mOuvQZeA8NIlIiKXPUyUYL9Ypt0NtmlkTZ+/6ECrktL4S9H88xWq5jFwlbq/9O 2o49q9lJ+YCo94b885JR90CrhBv/WxI= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-447-WPSCKSF5MbyVCAW4pbp2wQ-1; Sat, 17 Oct 2020 14:03:28 -0400 X-MC-Unique: WPSCKSF5MbyVCAW4pbp2wQ-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id D2F521006705; Sat, 17 Oct 2020 18:03:26 +0000 (UTC) Received: from localhost (ovpn-114-98.ams2.redhat.com [10.36.114.98]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5F96673667; Sat, 17 Oct 2020 18:03:23 +0000 (UTC) Date: Sat, 17 Oct 2020 19:03:22 +0100 From: "Richard W.M. Jones" To: Nick Wellnhofer Cc: Jeffrey Walton via xml , libguestfs@redhat.com, Eric Blake , Stefano Garzarella Message-ID: <20201017180322.GN30079@redhat.com> References: <20201017102431.GA9756@redhat.com> MIME-Version: 1.0 In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=rjones@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit Subject: Re: [xml] Why does libxml2 limit port numbers to 999,999,999? X-BeenThere: xml@gnome.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: The Gnome XML library mailing-list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 17 Oct 2020 18:03:34 -0000 On Sat, Oct 17, 2020 at 06:32:18PM +0200, Nick Wellnhofer wrote: > On Oct 17, 2020, at 12:24 , Richard W.M. Jones via xml wrote: > > It seems like libxml2 chose to do this for convenience rather than > > correctness. > > Yes, this is an arbitrary limit introduced to avoid integer overflow. > > > I think it should accept port numbers at least up to > > signed int (the type used to store port numbers), and give an error if > > the port number overflows. > > This is fixed now: https://gitlab.gnome.org/GNOME/libxml2/-/commit/b46016b8705b041c0678dd45e445dc73674b75d0 Oh that's great thanks. Can confirm it works for me (up to INT_MAX). > > Also could the uri->port field be changed to unsigned int without > > breaking ABI? > > It’s a public struct member, so strictly speaking, no. But the risk > to break stuff seems low. This would allow us to go to 2^32-1 which is the full range of port numbers for AF_VSOCK. ** Stefano ** Do you think this is worth it for the vsock protocol? I'm not sure how often huge port numbers are used - I only hit this bug because I was choosing random port numbers in a test case. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com libguestfs lets you edit virtual machines. Supports shell scripting, bindings from many languages. http://libguestfs.org From enh@google.com Tue Oct 27 18:33:38 2020 Return-Path: X-Original-To: xml@gnome.org Delivered-To: xml@gnome.org Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp.gnome.org (Postfix) with ESMTP id 3C6BFA02D3 for ; Tue, 27 Oct 2020 18:33:38 +0000 (UTC) X-Virus-Scanned: by amavisd-new at gnome.org X-Spam-Flag: NO X-Spam-Score: -16.601 X-Spam-Level: X-Spam-Status: No, score=-16.601 tagged_above=-999 required=6.2 tests=[BAYES_00=-1, DKIMWL_WL_MED=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, ENV_AND_HDR_SPF_MATCH=-0.5, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, USER_IN_DEF_DKIM_WL=-7.5, USER_IN_DEF_SPF_WL=-7.5] autolearn=no autolearn_force=no Received: from smtp.gnome.org ([127.0.0.1]) by localhost (restaurant.gnome.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id iPhlr9z8flNX for ; Tue, 27 Oct 2020 18:33:36 +0000 (UTC) Received: from mail-lf1-x12e.google.com (mail-lf1-x12e.google.com [IPv6:2a00:1450:4864:20::12e]) by smtp.gnome.org (Postfix) with ESMTPS id 13D2CA0564 for ; Tue, 27 Oct 2020 18:33:35 +0000 (UTC) Received: by mail-lf1-x12e.google.com with SMTP id h6so3658900lfj.3 for ; Tue, 27 Oct 2020 11:33:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:from:date:message-id:subject:to; bh=YLA8c4MQt0oe9dqC1m7gvaKHP2yov0MFkX1h74eJ3ug=; b=KagRgjDy5uNChiAvq7eSxqWOHfgkfeArifcJxYB75qP6nMPzg8d0xBxDLT9ykWfudw qawbTR+0FCkv4s7n7B//K9LROuwtJb2NXwloEjAUj0zcc355pogFKXZHcNSEjKu4Pjc8 Ap2ULaD7WpE4N9O85EzN8KyWzVoro9XuXc1IEilV+5C8I/FiFgNtp6pojdRMATW73Zjy W3iv2cD/rLdnmgmkCyBj1CwLw+FN7BEWrqRFh81z2UWtb8NZllEs0IHQNBrOyl78cgfs 3wsKrGRCyFzmsg6LyrMwNO8YbSrK+9e+ryE5q3oDMa3hezWPvkB2QiHa7YvJX4Jg7Pjr x9Kg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=YLA8c4MQt0oe9dqC1m7gvaKHP2yov0MFkX1h74eJ3ug=; b=NZJrTbGHeAzYvffMfpudwEIog26VKPZ3PvhwrB9gPiRUbVj9BIzEa9vefi/GosqBTi +cDwfxeVyVa8Gm6yXunf5Mi9taelkYXQ1ZuGWOHK1KDKB6ePSBLAkM5D/S8QDj5HnA7r IvXa4mY2ZN2JGy57LEl2znJxmyeNN/JbrHr9OpzG4wT0axKx4aT4EF/XvRtnTycYZnXn aCy6YTaQ4iHcw5MsamE6DHOh3/7wHK0Y75+Zv1EV5BLa5+odZ3fHE160dsfjz969gr0n Qs9/tOlwWPAScOwwxr5oOFohhAOiB83GX1KzfZzU4kw6MlZY8OOA082/U5HHkE+5E6CG LBwQ== X-Gm-Message-State: AOAM533CcBOO/Wjp6Nq5JR6g4yJo7Cep7ChiqNJ25Hf5+gThcoig/r2B 4a3CvDtxHPNd3uyaG0TA2BHTZMLt2DZYYP3kbJLlUZXHpW/pyg== X-Google-Smtp-Source: ABdhPJweSSL7yY55rQcfigDz+sVthiN5SMyM+NRSY0jPLT4v3/ECo5TxEUnG3v2TEosrv5jNIwQTmBEpa+4JGhIIU80= X-Received: by 2002:ac2:4204:: with SMTP id y4mr1477928lfh.224.1603823613301; Tue, 27 Oct 2020 11:33:33 -0700 (PDT) MIME-Version: 1.0 From: enh Date: Tue, 27 Oct 2020 11:33:21 -0700 Message-ID: To: xml@gnome.org Content-Type: multipart/mixed; boundary="000000000000c1a1c605b2ab4804" Subject: [xml] [PATCH] Fix xmlURIEscape memory leaks. X-BeenThere: xml@gnome.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: The Gnome XML library mailing-list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 27 Oct 2020 18:33:38 -0000 --000000000000c1a1c605b2ab4804 Content-Type: text/plain; charset="UTF-8" Found by running the fuzz/uri.c fuzzer under asan (internal Android bug 171610679). Always free `ret` when exiting on failure. I've moved the definition of NULLCHK down past where ret is always initialized to make it clear that this is safe. This patch also fixes the indentation of two of the NULLCHK call sites to make it more obvious that NULLCHK isn't `if`-like. --- uri.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) --000000000000c1a1c605b2ab4804 Content-Type: text/x-patch; charset="US-ASCII"; name="0001-Fix-xmlURIEscape-memory-leaks.patch" Content-Disposition: attachment; filename="0001-Fix-xmlURIEscape-memory-leaks.patch" Content-Transfer-Encoding: base64 Content-ID: X-Attachment-Id: f_kgsb5ohd0 RnJvbSBkMDEyZWI4MGU1M2EzMTE5OGIyZWI5YWI2YmMxMDk4MzViMDYwNjExIE1vbiBTZXAgMTcg MDA6MDA6MDAgMjAwMQpGcm9tOiBFbGxpb3R0IEh1Z2hlcyA8ZW5oQGdvb2dsZS5jb20+CkRhdGU6 IFR1ZSwgMjcgT2N0IDIwMjAgMTE6Mjk6MjAgLTA3MDAKU3ViamVjdDogW1BBVENIXSBGaXggeG1s VVJJRXNjYXBlIG1lbW9yeSBsZWFrcy4KCkZvdW5kIGJ5IHJ1bm5pbmcgdGhlIGZ1enovdXJpLmMg ZnV6emVyIHVuZGVyIGFzYW4gKGludGVybmFsIEFuZHJvaWQgYnVnCjE3MTYxMDY3OSkuCgpBbHdh eXMgZnJlZSBgcmV0YCB3aGVuIGV4aXRpbmcgb24gZmFpbHVyZS4gSSd2ZSBtb3ZlZCB0aGUgZGVm aW5pdGlvbiBvZgpOVUxMQ0hLIGRvd24gcGFzdCB3aGVyZSByZXQgaXMgYWx3YXlzIGluaXRpYWxp emVkIHRvIG1ha2UgaXQgY2xlYXIgdGhhdAp0aGlzIGlzIHNhZmUuCgpUaGlzIHBhdGNoIGFsc28g Zml4ZXMgdGhlIGluZGVudGF0aW9uIG9mIHR3byBvZiB0aGUgTlVMTENISyBjYWxsIHNpdGVzCnRv IG1ha2UgaXQgbW9yZSBvYnZpb3VzIHRoYXQgTlVMTENISyBpc24ndCBgaWZgLWxpa2UuCi0tLQog dXJpLmMgfCAxNyArKysrKysrKystLS0tLS0tLQogMSBmaWxlIGNoYW5nZWQsIDkgaW5zZXJ0aW9u cygrKSwgOCBkZWxldGlvbnMoLSkKCmRpZmYgLS1naXQgYS91cmkuYyBiL3VyaS5jCmluZGV4IDdl OWE5ZjQ0Li44MjA0ODI1ZiAxMDA2NDQKLS0tIGEvdXJpLmMKKysrIGIvdXJpLmMKQEAgLTE3NTQs MTEgKzE3NTQsNiBAQCB4bWxVUklFc2NhcGUoY29uc3QgeG1sQ2hhciAqIHN0cikKICAgICB4bWxV UklQdHIgdXJpOwogICAgIGludCByZXQyOwogCi0jZGVmaW5lIE5VTExDSEsocCkgaWYoIXApIHsg XAotICAgICAgICAgeG1sVVJJRXJyTWVtb3J5KCJlc2NhcGluZyBVUkkgdmFsdWVcbiIpOyBcCi0g ICAgICAgICB4bWxGcmVlVVJJKHVyaSk7IFwKLSAgICAgICAgIHJldHVybiBOVUxMOyB9IFwKLQog ICAgIGlmIChzdHIgPT0gTlVMTCkKICAgICAgICAgcmV0dXJuIChOVUxMKTsKIApAQCAtMTc4MCw2 ICsxNzc1LDEyIEBAIHhtbFVSSUVzY2FwZShjb25zdCB4bWxDaGFyICogc3RyKQogCiAgICAgcmV0 ID0gTlVMTDsKIAorI2RlZmluZSBOVUxMQ0hLKHApIGlmKCFwKSB7IFwKKyAgICAgICAgIHhtbFVS SUVyck1lbW9yeSgiZXNjYXBpbmcgVVJJIHZhbHVlXG4iKTsgXAorICAgICAgICAgeG1sRnJlZVVS SSh1cmkpOyBcCisgICAgICAgICB4bWxGcmVlKHJldCk7IFwKKyAgICAgICAgIHJldHVybiBOVUxM OyB9IFwKKwogICAgIGlmICh1cmktPnNjaGVtZSkgewogICAgICAgICBzZWdtZW50ID0geG1sVVJJ RXNjYXBlU3RyKEJBRF9DQVNUIHVyaS0+c2NoZW1lLCBCQURfQ0FTVCAiKy0uIik7CiAgICAgICAg IE5VTExDSEsoc2VnbWVudCkKQEAgLTE4MDAsNyArMTgwMSw3IEBAIHhtbFVSSUVzY2FwZShjb25z dCB4bWxDaGFyICogc3RyKQogICAgIGlmICh1cmktPnVzZXIpIHsKICAgICAgICAgc2VnbWVudCA9 IHhtbFVSSUVzY2FwZVN0cihCQURfQ0FTVCB1cmktPnVzZXIsIEJBRF9DQVNUICI7OiY9KyQsIik7 CiAgICAgICAgIE5VTExDSEsoc2VnbWVudCkKLQkJcmV0ID0geG1sU3RyY2F0KHJldCxCQURfQ0FT VCAiLy8iKTsKKyAgICAgICAgcmV0ID0geG1sU3RyY2F0KHJldCxCQURfQ0FTVCAiLy8iKTsKICAg ICAgICAgcmV0ID0geG1sU3RyY2F0KHJldCwgc2VnbWVudCk7CiAgICAgICAgIHJldCA9IHhtbFN0 cmNhdChyZXQsIEJBRF9DQVNUICJAIik7CiAgICAgICAgIHhtbEZyZWUoc2VnbWVudCk7CkBAIC0x ODA5LDggKzE4MTAsOCBAQCB4bWxVUklFc2NhcGUoY29uc3QgeG1sQ2hhciAqIHN0cikKICAgICBp ZiAodXJpLT5zZXJ2ZXIpIHsKICAgICAgICAgc2VnbWVudCA9IHhtbFVSSUVzY2FwZVN0cihCQURf Q0FTVCB1cmktPnNlcnZlciwgQkFEX0NBU1QgIi8/OzpAIik7CiAgICAgICAgIE5VTExDSEsoc2Vn bWVudCkKLQkJaWYgKHVyaS0+dXNlciA9PSBOVUxMKQotCQlyZXQgPSB4bWxTdHJjYXQocmV0LCBC QURfQ0FTVCAiLy8iKTsKKyAgICAgICAgaWYgKHVyaS0+dXNlciA9PSBOVUxMKQorICAgICAgICAg ICAgcmV0ID0geG1sU3RyY2F0KHJldCwgQkFEX0NBU1QgIi8vIik7CiAgICAgICAgIHJldCA9IHht bFN0cmNhdChyZXQsIHNlZ21lbnQpOwogICAgICAgICB4bWxGcmVlKHNlZ21lbnQpOwogICAgIH0K LS0gCjIuMjkuMC5yYzIuMzA5LmczNzRmODFkN2FlLWdvb2cKCg== --000000000000c1a1c605b2ab4804--