<html>
    <head>
      <base href="https://bugzilla.netfilter.org/" />
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - incorrect handling of json_unpack return value in json_verify_metainfo"
   href="https://bugzilla.netfilter.org/show_bug.cgi?id=1490">1490</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>incorrect handling of json_unpack return value in json_verify_metainfo
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>nftables
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>unspecified
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>x86_64
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>minor
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P5
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>nft
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>pablo@netfilter.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>niels@qacafe.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>According to the libjansson documenatation, json_unpack returns 0 on success
and -1 on failure:
<a href="https://jansson.readthedocs.io/en/latest/apiref.html#c.json_unpack">https://jansson.readthedocs.io/en/latest/apiref.html#c.json_unpack</a>

However, json_verify_metainfo in src/parser_json.c calls json_unpack but treats
a non-zero return value as a failure:
<a href="https://git.netfilter.org/nftables/tree/src/parser_json.c#n3748">https://git.netfilter.org/nftables/tree/src/parser_json.c#n3748</a>

The documentation indicates that the metainfo object can provided as input in
order to verify that nft supports a given JSON schema version:
<a href="https://git.netfilter.org/nftables/tree/doc/libnftables-json.adoc#n66">https://git.netfilter.org/nftables/tree/doc/libnftables-json.adoc#n66</a>

However, the bug makes it appear that nft supports *any* schema version.  The
only way to make nft reject the schema version is to encode the
"json_schema_version" field as something other than an integer, which causes
json_verify_metainfo to compare the uninitialized local variable schema_version
against JSON_SCHEMA_VERSION, leading to a confusing error message:

# nft -jae '{"nftables": [{"metainfo": {"json_schema_version": 999}}]}'
{"nftables": [{"metainfo": {"json_schema_version": 999}}]}
# echo $?
0

# nft -jae '{"nftables": [{"metainfo": {"json_schema_version": "1"}}]}'
internal:0:0-0: Error: Schema version 31509440 not supported, maximum supported
version is 1
internal:0:0-0: Error: Metainfo verification failed.
# echo $?
1

Please let me know if I can provide any other information.  I'm using nft
v0.9.6, but it looks to me like the bug still exists in master.</pre>
        </div>
      </p>
      <hr>
      <span>You are receiving this mail because:</span>
      
      <ul>
          <li>You are watching all bug changes.</li>
      </ul>
    </body>
</html>