Accept hex format for pdelete and ptrans commands
authorChristof Schmitt <cs@samba.org>
Mon, 6 Jul 2015 21:32:15 +0000 (14:32 -0700)
committerMartin Schwenke <martin@meltin.net>
Wed, 24 Feb 2016 10:44:28 +0000 (21:44 +1100)
Signed-off-by: Christof Schmitt <cs@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
(Imported from commit cd55349e9b0cfc9bb8c04a5cfa3c142efead6b83)

tools/ctdb.c

index eded98f73d87c711ba0fad0c4fe5c50844a33996..b44d9030ed2e7b02f9ec99977999c8b5058cb244 100644 (file)
@@ -4349,8 +4349,12 @@ static int control_pdelete(struct ctdb_context *ctdb, int argc, const char **arg
                return -1;
        }
 
-       key.dptr = discard_const(argv[1]);
-       key.dsize = strlen(argv[1]);
+       key = strtodata(tmp_ctx, argv[1], strlen(argv[1]));
+       if (key.dptr == NULL) {
+               printf("Failed to convert \"%s\" into a TDB_DATA\n", argv[1]);
+               return -1;
+       }
+
        ret = ctdb_transaction_store(h, key, tdb_null);
        if (ret != 0) {
                DEBUG(DEBUG_ERR, ("Failed to delete record\n"));
@@ -4391,8 +4395,7 @@ static const char *ptrans_parse_string(TALLOC_CTX *mem_ctx, const char *s,
                n = strcspn(t, "\"");
                if (t[n] == '"') {
                        if (n > 0) {
-                               data->dsize = n;
-                               data->dptr = talloc_memdup(mem_ctx, t, n);
+                               *data = strtodata(mem_ctx, t, n);
                                CTDB_NOMEM_ABORT(data->dptr);
                        }
                        ret = t + n + 1;