Script 'mail_helper' called by obssrc
Hello community,

here is the log from the commit of package nbdkit for openSUSE:Factory checked 
in at 2026-02-13 12:43:41
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/nbdkit (Old)
 and      /work/SRC/openSUSE:Factory/.nbdkit.new.1977 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "nbdkit"

Fri Feb 13 12:43:41 2026 rev:27 rq:1332754 version:1.46.2

Changes:
--------
--- /work/SRC/openSUSE:Factory/nbdkit/nbdkit.changes    2026-01-06 
17:46:38.246694277 +0100
+++ /work/SRC/openSUSE:Factory/.nbdkit.new.1977/nbdkit.changes  2026-02-13 
12:45:11.890415401 +0100
@@ -1,0 +2,20 @@
+Thu Feb 12 16:51:33 UTC 2026 - Charles Arnold <[email protected]>
+
+- Update to version 1.46.2: (jsc#PED-14625)
+  * Version 1.46.2.
+  * sparse-random: Parse runlength parameter using nbdkit_parse_size
+  * vram: Link to blkdiscard(8)
+  * tests/functions.sh.in: Remove obsolete comment
+  * common/utils/utils.h: Add C++ boilerplate
+  * map: Fix documentation about changing the size of the disk
+  * configure.ac: Remove use of "which" command
+  * vddk: Test with VDDK 9.0.1.0
+  * qcow2dec: Don't pass flags from .extents through to .pread
+  * file: Change calculations of block size hints for block devices
+  * todo: Add note about problems with file plugin block_size
+  * file: Don't advertise minimum_io_size > 64K (the max supported by NBD)
+  * blocksize-policy: Fix assertion failure on unaligned block status
+  * python: Sort documentation for module functions in order
+  * python: Link to C man pages for module functions
+
+-------------------------------------------------------------------

Old:
----
  nbdkit-1.46.1.tar.xz

New:
----
  nbdkit-1.46.2.tar.xz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ nbdkit.spec ++++++
--- /var/tmp/diff_new_pack.Tlw4uH/_old  2026-02-13 12:45:12.678448405 +0100
+++ /var/tmp/diff_new_pack.Tlw4uH/_new  2026-02-13 12:45:12.682448572 +0100
@@ -27,7 +27,7 @@
 %global broken_test_arches %{arm} aarch64 %{ix86}
 
 Name:           nbdkit
-Version:        1.46.1
+Version:        1.46.2
 Release:        0
 Summary:        Network Block Device server
 License:        BSD-3-Clause
@@ -182,6 +182,7 @@
 
 
 
+
 # The plugins below have non-trivial dependencies are so are
 # packaged separately.
 %package cdi-plugin
@@ -202,6 +203,7 @@
 
 
 
+
 
 
 

++++++ _service ++++++
--- /var/tmp/diff_new_pack.Tlw4uH/_old  2026-02-13 12:45:12.722450248 +0100
+++ /var/tmp/diff_new_pack.Tlw4uH/_new  2026-02-13 12:45:12.730450583 +0100
@@ -1,7 +1,7 @@
 <services>
   <service name="tar_scm" mode="manual">
     <param name="filename">nbdkit</param>
-    <param name="revision">v1.46.1</param>
+    <param name="revision">v1.46.2</param>
     <param name="scm">git</param>
     <param name="submodules">disable</param>
     <param name="url">https://gitlab.com/nbdkit/nbdkit.git</param>

++++++ _servicedata ++++++
--- /var/tmp/diff_new_pack.Tlw4uH/_old  2026-02-13 12:45:12.766452090 +0100
+++ /var/tmp/diff_new_pack.Tlw4uH/_new  2026-02-13 12:45:12.774452426 +0100
@@ -1,6 +1,6 @@
 <servicedata>
 <service name="tar_scm">
                 <param name="url">https://gitlab.com/nbdkit/nbdkit.git</param>
-              <param 
name="changesrevision">e1d3d4106c06d3c448e59d16aa756353babe6074</param></service></servicedata>
+              <param 
name="changesrevision">574bf19998b06515ef3df47bc8eabd36b632eb2a</param></service></servicedata>
 (No newline at EOF)
 

++++++ nbdkit-1.46.1.tar.xz -> nbdkit-1.46.2.tar.xz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/nbdkit-1.46.1/common/utils/utils.h 
new/nbdkit-1.46.2/common/utils/utils.h
--- old/nbdkit-1.46.1/common/utils/utils.h      2026-01-02 11:07:39.000000000 
+0100
+++ new/nbdkit-1.46.2/common/utils/utils.h      2026-02-08 20:08:24.000000000 
+0100
@@ -33,6 +33,10 @@
 #ifndef NBDKIT_UTILS_H
 #define NBDKIT_UTILS_H
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #include <stdbool.h>
 
 extern void shell_quote (const char *str, FILE *fp);
@@ -54,4 +58,8 @@
 extern int64_t device_size (int fd, const struct stat *statbuf);
 #endif
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* NBDKIT_UTILS_H */
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/nbdkit-1.46.1/configure.ac 
new/nbdkit-1.46.2/configure.ac
--- old/nbdkit-1.46.1/configure.ac      2026-01-02 11:07:39.000000000 +0100
+++ new/nbdkit-1.46.2/configure.ac      2026-02-08 20:08:24.000000000 +0100
@@ -31,7 +31,7 @@
 
 m4_define([NBDKIT_VERSION_MAJOR], [1])
 m4_define([NBDKIT_VERSION_MINOR], [46])
-m4_define([NBDKIT_VERSION_MICRO], [1])
+m4_define([NBDKIT_VERSION_MICRO], [2])
 AC_INIT([nbdkit],
         NBDKIT_VERSION_MAJOR.NBDKIT_VERSION_MINOR.NBDKIT_VERSION_MICRO)
 AC_CONFIG_MACRO_DIR([m4])
@@ -205,7 +205,7 @@
 dnl Bash must be at least version 4.  If it is too old, fail hard
 dnl with a good diagnostic.  Note macOS ships an ancient version
 dnl of bash (https://gitlab.com/nbdkit/nbdkit/-/issues/21)
-bash=`which bash`
+bash=$(command -v bash)
 AC_MSG_CHECKING([for the major version of $bash])
 bash_major=`bash -c 'echo ${BASH_VERSINFO:-0}'`
 AC_MSG_RESULT([$bash_major])
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/nbdkit-1.46.1/docs/nbdkit-filter.pod 
new/nbdkit-1.46.2/docs/nbdkit-filter.pod
--- old/nbdkit-1.46.1/docs/nbdkit-filter.pod    2026-01-02 11:07:39.000000000 
+0100
+++ new/nbdkit-1.46.2/docs/nbdkit-filter.pod    2026-02-08 20:08:24.000000000 
+0100
@@ -1043,7 +1043,7 @@
 easier to ensure that the client only encounters aligned extents.
 
  int nbdkit_extents_aligned (nbdkit_next *next,
-                             uint32_t count, uint64_t offset,
+                             uint64_t count, uint64_t offset,
                              uint32_t flags, uint32_t align,
                              struct nbdkit_extents *extents, int *err);
 
@@ -1052,8 +1052,9 @@
 plugin returns differing extents within C<align> bytes, this function
 treats that portion of the disk as a single extent with zero and
 sparse status bits determined by the intersection of all underlying
-extents.  It is an error to call this function with C<count> or
-C<offset> that is not already aligned.
+extents.  This function supports unaligned C<offset> or C<count>, but
+the given C<extents> must begin at C<offset> and not have any extents
+added yet.
 
 =head2 C<.cache>
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/nbdkit-1.46.1/docs/nbdkit-security.pod 
new/nbdkit-1.46.2/docs/nbdkit-security.pod
--- old/nbdkit-1.46.1/docs/nbdkit-security.pod  2026-01-02 11:07:39.000000000 
+0100
+++ new/nbdkit-1.46.2/docs/nbdkit-security.pod  2026-02-08 20:08:24.000000000 
+0100
@@ -47,6 +47,12 @@
 here:
 
L<https://lists.libguestfs.org/archives/list/[email protected]/message/67E7AASHHADIY7VAD3FFW2I67LTWVWYF/>
 
+=head2 denial of service attack by client sending unaligned block status
+
+See the patch here:
+L<https://lists.libguestfs.org/archives/list/[email protected]/thread/EQTMAKGDP53WYOUBCEKWLCWAJHVUNSXX/>
+Full announcement and links to mitigation coming.
+
 =head1 SEE ALSO
 
 L<nbdkit(1)>.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/nbdkit-1.46.1/filters/map/nbdkit-map-filter.pod 
new/nbdkit-1.46.2/filters/map/nbdkit-map-filter.pod
--- old/nbdkit-1.46.1/filters/map/nbdkit-map-filter.pod 2026-01-02 
11:07:39.000000000 +0100
+++ new/nbdkit-1.46.2/filters/map/nbdkit-map-filter.pod 2026-02-08 
20:08:24.000000000 +0100
@@ -10,11 +10,12 @@
 =head1 DESCRIPTION
 
 C<nbdkit-map-filter> is an L<nbdkit(1)> filter which can remap parts
-of the underlying plugin, such as moving a sector or partition.  To
-select part of a disk, use L<nbdkit-offset-filter(1)> instead.  To
-select a partition, use L<nbdkit-partition-filter(1)>.  This filter
-cannot change the size of the disk, use L<nbdkit-truncate-filter(1)>
-to do that.
+of the underlying plugin, such as moving a sector or partition.
+
+To select part of a disk, use L<nbdkit-offset-filter(1)> instead.  To
+select a partition, use L<nbdkit-partition-filter(1)>.  Although this
+filter can change the size of the disk, L<nbdkit-truncate-filter(1)>
+is easier to use.
 
 =head1 EXAMPLES
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/nbdkit-1.46.1/filters/qcow2dec/qcow2dec.c 
new/nbdkit-1.46.2/filters/qcow2dec/qcow2dec.c
--- old/nbdkit-1.46.1/filters/qcow2dec/qcow2dec.c       2026-01-02 
11:07:39.000000000 +0100
+++ new/nbdkit-1.46.2/filters/qcow2dec/qcow2dec.c       2026-02-08 
20:08:24.000000000 +0100
@@ -924,7 +924,10 @@
     uint64_t file_offset;
     struct nbdkit_extent e = { .offset = offset, .length = cluster_size };
 
-    if (read_l2_entry (next, offset, flags, &l2_present, &l2_entry, err) == -1)
+    /* Note: Don't pass flags here, since this is expecting pread
+     * flags (always 0).
+     */
+    if (read_l2_entry (next, offset, 0, &l2_present, &l2_entry, err) == -1)
       return -1;
 
     /* L2 table is unallocated. */
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/nbdkit-1.46.1/include/nbdkit-filter.h 
new/nbdkit-1.46.2/include/nbdkit-filter.h
--- old/nbdkit-1.46.1/include/nbdkit-filter.h   2026-01-02 11:07:39.000000000 
+0100
+++ new/nbdkit-1.46.2/include/nbdkit-filter.h   2026-02-08 20:08:24.000000000 
+0100
@@ -135,7 +135,7 @@
                     NBDKIT_ATTRIBUTE_NONNULL ((1, 5)));
 NBDKIT_EXTERN_DECL (int, nbdkit_extents_aligned,
                     (nbdkit_next *next,
-                     uint32_t count, uint64_t offset,
+                     uint64_t count, uint64_t offset,
                      uint32_t flags, uint32_t align,
                      struct nbdkit_extents *extents, int *err)
                     NBDKIT_ATTRIBUTE_NONNULL ((1, 6, 7)));
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/nbdkit-1.46.1/plugins/file/file.c 
new/nbdkit-1.46.2/plugins/file/file.c
--- old/nbdkit-1.46.1/plugins/file/file.c       2026-01-02 11:07:39.000000000 
+0100
+++ new/nbdkit-1.46.2/plugins/file/file.c       2026-02-08 20:08:24.000000000 
+0100
@@ -414,7 +414,7 @@
 static void
 file_dump_plugin (void)
 {
-#if defined(BLKIOMIN) && defined(BLKIOOPT)
+#if defined(BLKSSZGET) && defined(BLKIOMIN) && defined(BLKIOOPT)
   printf ("file_block_size=yes\n");
 #endif
 #ifdef BLKROTATIONAL
@@ -741,26 +741,43 @@
 #endif
 
   h->minimum = h->preferred = h->maximum = 0;
-#if defined(BLKIOMIN) && defined(BLKIOOPT)
+#if defined(BLKSSZGET) && defined(BLKIOMIN) && defined(BLKIOOPT)
   if (h->is_block_device) {
-    unsigned int minimum_io_size = 0, optimal_io_size = 0;
+    int logical_block_size = 0;
+    unsigned minimum_io_size = 0, optimal_io_size = 0;
+
+    if (ioctl (h->fd, BLKSSZGET, &logical_block_size) == -1)
+      nbdkit_debug ("ioctl: %s: %s: %m", "BLKSSZGET", h->name);
 
     if (ioctl (h->fd, BLKIOMIN, &minimum_io_size) == -1)
-      nbdkit_debug ("cannot get BLKIOMIN: %s: %m", h->name);
+      nbdkit_debug ("ioctl: %s: %s: %m", "BLKIOMIN", h->name);
 
     if (ioctl (h->fd, BLKIOOPT, &optimal_io_size) == -1)
-      nbdkit_debug ("cannot get BLKIOOPT: %s: %m", h->name);
+      nbdkit_debug ("ioctl: %s: %s: %m", "BLKIOOPT", h->name);
     else if (optimal_io_size == 0)
       /* All devices in the Linux kernel except for MD report optimal
-       * as 0.  In that case guess a good value.
+       * as 0.  In that case use logical_block_size.
        */
-      optimal_io_size = MAX (minimum_io_size, 4096);
+      optimal_io_size = logical_block_size;
 
     /* Check the values are sane before using them. */
-    if (minimum_io_size >= 512 && is_power_of_2 (minimum_io_size) &&
-        optimal_io_size >= minimum_io_size && is_power_of_2 (optimal_io_size)) 
{
-      h->minimum = minimum_io_size;
-      h->preferred = optimal_io_size;
+    if (logical_block_size >= 512 && is_power_of_2 (logical_block_size) &&
+        minimum_io_size >= 512 && is_power_of_2 (minimum_io_size) &&
+        minimum_io_size >= logical_block_size &&
+        optimal_io_size >= 512 && is_power_of_2 (optimal_io_size) &&
+        optimal_io_size >= logical_block_size) {
+      /* The mapping from Linux kernel settings to NBD protocol block
+       * sizes is not obvious.  logical_block_size is the sector size,
+       * and anything smaller than this will cause a RMW cycle.  For
+       * the preferred size, we are advised to use the largest of
+       * minimum_io_size and optimal_io_size.  For this plugin maximum
+       * can be the largest that NBD can handle.
+       */
+
+      /* 64K is the largest minimum that the NBD protocol supports. */
+      h->minimum = MIN (65536, logical_block_size);
+
+      h->preferred = MAX (minimum_io_size, optimal_io_size);
       h->maximum = 0xffffffff;
     }
   }
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/nbdkit-1.46.1/plugins/python/nbdkit-python-plugin.pod 
new/nbdkit-1.46.2/plugins/python/nbdkit-python-plugin.pod
--- old/nbdkit-1.46.1/plugins/python/nbdkit-python-plugin.pod   2026-01-02 
11:07:39.000000000 +0100
+++ new/nbdkit-1.46.2/plugins/python/nbdkit-python-plugin.pod   2026-02-08 
20:08:24.000000000 +0100
@@ -119,46 +119,62 @@
 Send a debug message to stderr or syslog if verbose messages are
 enabled.
 
+See: L<nbdkit_debug(3)>
+
 =head3 C<nbdkit.disconnect(force)>
 
 Disconnect from the client.  If C<force> is C<True> then nbdkit will
 disconnect the client immediately.
 
+See: L<nbdkit_disconnect(3)>
+
 =head3 C<nbdkit.export_name()>
 
 Return the export name negotiated with the client as a Unicode string.
 Note this should not be trusted because the client can send whatever
 it wants.
 
+See: L<nbdkit_export_name(3)>
+
 =head3 C<nbdkit.is_tls()>
 
 Returns C<True> if the client completed TLS authentication, or
 C<False> if the connection is plaintext.
 
+See: L<nbdkit_is_tls(3)>
+
 =head3 C<nbdkit.nanosleep(secs, nsecs)>
 
 Sleep for seconds and nanoseconds.
 
+See: L<nbdkit_nanosleep(3)>
+
 =head3 C<nbdkit.parse_bool(str)>
 
 Parse a human-readable boolean (such as "yes" or "false"), returning
 C<True> or C<False>.  Wraps the L<nbdkit_parse_bool(3)> function.
 
+See: L<nbdkit_parse_bool(3)>
+
 =head3 C<nbdkit.parse_delay(what, str)>
 
 Parse a delay or sleep (such as "10ms") into a pair (sec, nsec).
 Wraps the L<nbdkit_parse_delay(3)> function.
 
-=head3 C<nbdkit.parse_size(str)>
-
-Parse a string (such as "100M") into a size in bytes.  Wraps the
-L<nbdkit_parse_size(3)> C function.
+See: L<nbdkit_parse_delay(3)>
 
 =head3 C<nbdkit.parse_probability(what, str)>
 
 Parse a string (such as "100%") into a probability, returning a
-floating point number.  Wraps the L<nbdkit_parse_probability(3)>
-function.
+floating point number.
+
+See: L<nbdkit_parse_probability(3)>
+
+=head3 C<nbdkit.parse_size(str)>
+
+Parse a string (such as "100M") into a size in bytes.
+
+See: L<nbdkit_parse_size(3)>
 
 =head3 C<nbdkit.peer_pid()>,
 C<nbdkit.peer_uid()>,
@@ -171,22 +187,27 @@
 security context is usually the SELinux label, IPSEC label or
 NetLabel.
 
+See: L<nbdkit_peer_pid(3)>, L<nbdkit_peer_uid(3)>,
+L<nbdkit_peer_gid(3)> and L<nbdkit_peer_security_context(3)>
+
 =head3 C<nbdkit.peer_tls_dn()>
 
 Return the client TLS Distinguished Name.
-See L<nbdkit_peer_tls_dn(3)>.
+
+See: L<nbdkit_peer_tls_dn(3)>
 
 =head3 C<nbdkit.peer_tls_issuer_dn()>
 
 Return the client certificate issuer's TLS Distinguished Name.
-See L<nbdkit_peer_tls_issuer_dn(3)>.
+
+See: L<nbdkit_peer_tls_issuer_dn(3)>
 
 =head3 C<nbdkit.read_password(value)>
 
 Read a password from a config parameter.  This returns the password as
-a Python C<bytes> object.  See L<nbdkit_read_password(3)> for more
-information on the different ways that the C<value> parameter can be
-parsed.
+a Python C<bytes> object.
+
+See: L<nbdkit_read_password(3)>
 
 =head3 C<nbdkit.set_error(err)>
 
@@ -201,15 +222,21 @@
      nbdkit.set_error(errno.EPERM)
      raise RuntimeError()
 
+See: L<nbdkit_set_error(3)>
+
 =head3 C<nbdkit.shutdown()>
 
 Request asynchronous server shutdown.
 
+See: L<nbdkit_shutdown(3)>
+
 =head3 C<nbdkit.stdio_safe()>
 
 Returns C<True> if it is safe to interact with stdin and stdout
 during the configuration phase.
 
+See: L<nbdkit_stdio_safe(3)>
+
 =head2 Module constants
 
 After C<import nbdkit> the following constants are available.  These
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/nbdkit-1.46.1/plugins/sparse-random/sparse-random.c 
new/nbdkit-1.46.2/plugins/sparse-random/sparse-random.c
--- old/nbdkit-1.46.1/plugins/sparse-random/sparse-random.c     2026-01-02 
11:07:39.000000000 +0100
+++ new/nbdkit-1.46.2/plugins/sparse-random/sparse-random.c     2026-02-08 
20:08:24.000000000 +0100
@@ -105,12 +105,14 @@
     }
   }
   else if (strcmp (key, "runlength") == 0) {
-    if (nbdkit_parse_uint64_t ("runlength", value, &runlength) == -1)
+    r = nbdkit_parse_size (value);
+    if (r == -1)
       return -1;
-    if (runlength <= 0) {
+    if (r <= 0) {
       nbdkit_error ("runlength parameter must be > 0");
       return -1;
     }
+    runlength = r;
   }
   else if (strcmp (key, "random-content") == 0) {
     random_content = nbdkit_parse_bool (value);
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/nbdkit-1.46.1/plugins/vddk/nbdkit-vddk-plugin.pod 
new/nbdkit-1.46.2/plugins/vddk/nbdkit-vddk-plugin.pod
--- old/nbdkit-1.46.1/plugins/vddk/nbdkit-vddk-plugin.pod       2026-01-02 
11:07:39.000000000 +0100
+++ new/nbdkit-1.46.2/plugins/vddk/nbdkit-vddk-plugin.pod       2026-02-08 
20:08:24.000000000 +0100
@@ -439,7 +439,7 @@
 C<VixDiskLib_QueryAllocatedBlocks> API.  This is used to provide
 sparseness (extent) information over NBD.
 
-=item VDDK 9.0.0.0 (released Jun 2025)
+=item VDDK 9.0.1.0 (released Sep 2025)
 
 This is the latest version of VDDK that we have tested at the time of
 writing, but the plugin should work with future versions.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/nbdkit-1.46.1/plugins/vram/nbdkit-vram-plugin.pod 
new/nbdkit-1.46.2/plugins/vram/nbdkit-vram-plugin.pod
--- old/nbdkit-1.46.1/plugins/vram/nbdkit-vram-plugin.pod       2026-01-02 
11:07:39.000000000 +0100
+++ new/nbdkit-1.46.2/plugins/vram/nbdkit-vram-plugin.pod       2026-02-08 
20:08:24.000000000 +0100
@@ -91,8 +91,8 @@
 To limit the maximum amount of video RAM that will be used, use the
 optional C<size> parameter.
 
-If you trim the block device (eg. L<fstrim(8)>), video RAM is given
-back to the system.
+If you trim the block device (see L<blkdiscard(8)> and L<fstrim(8)>),
+video RAM is given back to the system.
 
 Currently you cannot limit the video RAM used independently of the
 virtual size of the disk (because it's not a good idea).
@@ -159,6 +159,7 @@
 L<nbdkit-memory-plugin(1)>,
 L<clinfo(1)>,
 L<radeontop(1)>,
+L<blkdiscard(8)>,
 L<fstrim(8)>.
 
 =head1 AUTHORS
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/nbdkit-1.46.1/server/extents.c 
new/nbdkit-1.46.2/server/extents.c
--- old/nbdkit-1.46.1/server/extents.c  2026-01-02 11:07:39.000000000 +0100
+++ new/nbdkit-1.46.2/server/extents.c  2026-02-08 20:08:24.000000000 +0100
@@ -213,7 +213,7 @@
 /* Compute aligned extents on behalf of a filter. */
 NBDKIT_DLL_PUBLIC int
 nbdkit_extents_aligned (struct context *next_c,
-                        uint32_t count, uint64_t offset,
+                        uint64_t count, uint64_t offset,
                         uint32_t flags, uint32_t align,
                         struct nbdkit_extents *exts, int *err)
 {
@@ -222,22 +222,25 @@
   struct nbdkit_extent *e, *e2;
   int64_t size;
 
+  assert (exts->extents.len == 0);
+  assert (exts->start == offset);
+
   size = next->get_size (next_c);
   if (size == -1) {
     *err = EIO;
     return -1;
   }
-  assert (IS_ALIGNED (offset, align));
-  assert (IS_ALIGNED (count, align) || offset + count == size);
+  exts->start = ROUND_DOWN (offset, align);
+  count = MIN (ROUND_UP (offset + count, align), size) - exts->start;
 
   /* Perform an initial query, then scan for the first unaligned extent. */
-  if (next->extents (next_c, count, offset, flags, exts, err) == -1)
+  if (next->extents (next_c, count, exts->start, flags, exts, err) == -1)
     return -1;
   for (i = 0; i < exts->extents.len; ++i) {
     e = &exts->extents.ptr[i];
     if (!IS_ALIGNED (e->length, align)) {
       /* If the unalignment is past align, just truncate and return early */
-      if (e->offset + e->length > offset + align) {
+      if (e->offset + e->length > exts->start + align) {
         e->length = ROUND_DOWN (e->length, align);
         exts->extents.len = i + !!e->length;
         exts->next = e->offset + e->length;
@@ -271,13 +274,13 @@
           CLEANUP_EXTENTS_FREE struct nbdkit_extents *extents2 = NULL;
 
           extents2 = nbdkit_extents_new (e->offset + e->length,
-                                         offset + align);
+                                         exts->start + align);
           if (extents2 == NULL) {
             *err = errno;
             return -1;
           }
           if (next->extents (next_c, align - e->length,
-                             offset + e->length,
+                             exts->start + e->length,
                              flags & ~NBDKIT_FLAG_REQ_ONE,
                              extents2, err) == -1)
             return -1;
@@ -298,7 +301,13 @@
       break;
     }
   }
-  /* Once we get here, all extents are aligned. */
+  /* Once we get here, all extents are aligned.  Trim back to the
+   * original offset if it was unaligned.
+   */
+  e = &exts->extents.ptr[0];
+  e->length -= offset - exts->start;
+  e->offset += offset - exts->start;
+  exts->start = offset;
   return 0;
 }
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/nbdkit-1.46.1/tests/functions.sh.in 
new/nbdkit-1.46.2/tests/functions.sh.in
--- old/nbdkit-1.46.1/tests/functions.sh.in     2026-01-02 11:07:39.000000000 
+0100
+++ new/nbdkit-1.46.2/tests/functions.sh.in     2026-02-08 20:08:24.000000000 
+0100
@@ -609,8 +609,7 @@
 # $port.
 #
 # This is inherently racy so we only use it where it's absolutely
-# necessary (eg. testing TLS because qemu cannot do TLS over a Unix
-# domain socket).
+# necessary.
 pick_unused_port ()
 {
     requires ss --version
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/nbdkit-1.46.1/tests/test-blocksize-policy-extents.sh 
new/nbdkit-1.46.2/tests/test-blocksize-policy-extents.sh
--- old/nbdkit-1.46.1/tests/test-blocksize-policy-extents.sh    2026-01-02 
11:07:39.000000000 +0100
+++ new/nbdkit-1.46.2/tests/test-blocksize-policy-extents.sh    2026-02-08 
20:08:24.000000000 +0100
@@ -40,6 +40,8 @@
 requires_run
 requires_plugin data
 requires_nbdinfo
+requires nbdsh --base-allocation --version
+requires_nbdsh_uri
 
 files="blocksize-policy-extents.out"
 rm -f $files
@@ -69,3 +71,58 @@
          0  4294967296    3  hole,zero
 4294967296         512    0  data
 EOF
+
+# Check that unaligned requests are rejected when required
+define script <<\EOF
+def print_extents(context, offset, extents, err):
+  assert context == nbd.CONTEXT_BASE_ALLOCATION;
+  print(extents)
+
+h.set_strict_mode(0)
+try:
+  h.block_status(511, 512, print_extents)
+except nbd.Error:
+  print("detected misaligned count")
+try:
+  h.block_status(512, 511, print_extents)
+except nbd.Error:
+  print("detected misaligned offset")
+h.block_status(513, 32256, print_extents)
+h.block_status(1, 32768, print_extents)
+EOF
+export script
+nbdkit data "@32k 1" --filter=blocksize-policy \
+       blocksize-minimum=512 blocksize-error-policy=error \
+       --run 'nbdsh --base-allocation -u "$uri" -c "$script"' \
+       > blocksize-policy-extents.out
+diff -u - blocksize-policy-extents.out <<EOF
+detected misaligned count
+detected misaligned offset
+[512, 3]
+[1, 0]
+EOF
+
+# Check that unaligned requests still work when permitted (a user could trigger
+# an assertion failure prior to 1.48, as a minor security flaw)
+define script <<\EOF
+def print_extents(context, offset, extents, err):
+  assert context == nbd.CONTEXT_BASE_ALLOCATION;
+  print(extents)
+
+h.set_strict_mode(0)
+h.block_status(511, 512, print_extents)
+h.block_status(512, 511, print_extents)
+h.block_status(2, 32767, print_extents)
+h.block_status(1, 32768, print_extents)
+EOF
+export script
+nbdkit data "@32k 1" --filter=blocksize-policy \
+       blocksize-minimum=512 blocksize-error-policy=allow \
+       --run 'nbdsh --base-allocation -u "$uri" -c "$script"' \
+       > blocksize-policy-extents.out
+diff -u - blocksize-policy-extents.out <<EOF
+[32256, 3]
+[32257, 3]
+[1, 3]
+[1, 0]
+EOF

Reply via email to