Print this page
5847 libzfs_diff should check zfs_prop_get() return

Split Close
Expand all
Collapse all
          --- old/usr/src/lib/libzfs/common/libzfs_diff.c
          +++ new/usr/src/lib/libzfs/common/libzfs_diff.c
↓ open down ↓ 13 lines elided ↑ open up ↑
  14   14   * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15   15   * If applicable, add the following below this CDDL HEADER, with the
  16   16   * fields enclosed by brackets "[]" replaced with your own identifying
  17   17   * information: Portions Copyright [yyyy] [name of copyright owner]
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
  21   21  
  22   22  /*
  23   23   * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
       24 + * Copyright 2015 Nexenta Systems, Inc. All rights reserved.
  24   25   */
  25   26  
  26   27  /*
  27   28   * zfs diff support
  28   29   */
  29   30  #include <ctype.h>
  30   31  #include <errno.h>
  31   32  #include <libintl.h>
  32   33  #include <string.h>
  33   34  #include <sys/types.h>
↓ open down ↓ 575 lines elided ↑ open up ↑
 609  610                  char origin[ZFS_MAXNAMELEN];
 610  611                  zprop_source_t src;
 611  612                  zfs_handle_t *zhp;
 612  613  
 613  614                  di->ds = zfs_alloc(di->zhp->zfs_hdl, tdslen + 1);
 614  615                  (void) strncpy(di->ds, tosnap, tdslen);
 615  616                  di->ds[tdslen] = '\0';
 616  617  
 617  618                  zhp = zfs_open(hdl, di->ds, ZFS_TYPE_FILESYSTEM);
 618  619                  while (zhp != NULL) {
 619      -                        (void) zfs_prop_get(zhp, ZFS_PROP_ORIGIN,
 620      -                            origin, sizeof (origin), &src, NULL, 0, B_FALSE);
 621      -
      620 +                        if (zfs_prop_get(zhp, ZFS_PROP_ORIGIN, origin,
      621 +                            sizeof (origin), &src, NULL, 0, B_FALSE) != 0) {
      622 +                                (void) zfs_close(zhp);
      623 +                                zhp = NULL;
      624 +                                break;
      625 +                        }
 622  626                          if (strncmp(origin, fromsnap, fsnlen) == 0)
 623  627                                  break;
 624  628  
 625  629                          (void) zfs_close(zhp);
 626  630                          zhp = zfs_open(hdl, origin, ZFS_TYPE_FILESYSTEM);
 627  631                  }
 628  632  
 629  633                  if (zhp == NULL) {
 630  634                          (void) snprintf(di->errbuf, sizeof (di->errbuf),
 631  635                              dgettext(TEXT_DOMAIN,
↓ open down ↓ 195 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX