Print this page
5515 dataset user hold doesn't reject empty tags

@@ -25,11 +25,11 @@
  * Copyright 2011 Nexenta Systems, Inc.  All rights reserved.
  * Copyright (c) 2014, Joyent, Inc. All rights reserved.
  * Copyright (c) 2011, 2014 by Delphix. All rights reserved.
  * Copyright (c) 2013 by Saso Kiselkov. All rights reserved.
  * Copyright (c) 2013 Steven Hartland. All rights reserved.
- * Copyright (c) 2014, Nexenta Systems, Inc. All rights reserved.
+ * Copyright (c) 2015, Nexenta Systems, Inc. All rights reserved.
  */
 
 /*
  * ZFS ioctls.
  *

@@ -5108,19 +5108,33 @@
  */
 /* ARGSUSED */
 static int
 zfs_ioc_hold(const char *pool, nvlist_t *args, nvlist_t *errlist)
 {
+        nvpair_t *pair;
         nvlist_t *holds;
         int cleanup_fd = -1;
         int error;
         minor_t minor = 0;
 
         error = nvlist_lookup_nvlist(args, "holds", &holds);
         if (error != 0)
                 return (SET_ERROR(EINVAL));
 
+        /* make sure the user didn't pass us any invalid (empty) tags */
+        for (pair = nvlist_next_nvpair(holds, NULL); pair != NULL;
+            pair = nvlist_next_nvpair(holds, pair)) {
+                char *htag;
+
+                error = nvpair_value_string(pair, &htag);
+                if (error != 0)
+                        return (SET_ERROR(error));
+
+                if (strlen(htag) == 0)
+                        return (SET_ERROR(EINVAL));
+        }
+
         if (nvlist_lookup_int32(args, "cleanup_fd", &cleanup_fd) == 0) {
                 error = zfs_onexit_fd_hold(cleanup_fd, &minor);
                 if (error != 0)
                         return (error);
         }