Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/external/gpl2/lvm2/dist/libdm/ioctl Handle NULL params, fix ...



details:   https://anonhg.NetBSD.org/src/rev/69eefd54a5ca
branches:  trunk
changeset: 466148:69eefd54a5ca
user:      mlelstv <mlelstv%NetBSD.org@localhost>
date:      Sat Dec 14 09:05:30 2019 +0000

description:
Handle NULL params, fix error paths.

diffstat:

 external/gpl2/lvm2/dist/libdm/ioctl/libdm_netbsd.c |  17 +++++++++--------
 1 files changed, 9 insertions(+), 8 deletions(-)

diffs (45 lines):

diff -r f1443e96f790 -r 69eefd54a5ca external/gpl2/lvm2/dist/libdm/ioctl/libdm_netbsd.c
--- a/external/gpl2/lvm2/dist/libdm/ioctl/libdm_netbsd.c        Sat Dec 14 07:45:20 2019 +0000
+++ b/external/gpl2/lvm2/dist/libdm/ioctl/libdm_netbsd.c        Sat Dec 14 09:05:30 2019 +0000
@@ -1,4 +1,4 @@
-/*      $NetBSD: libdm_netbsd.c,v 1.7 2011/02/08 03:26:12 haad Exp $        */
+/*      $NetBSD: libdm_netbsd.c,v 1.8 2019/12/14 09:05:30 mlelstv Exp $        */
 
 /*
  * Copyright (c) 1996, 1997, 1998, 1999, 2002 The NetBSD Foundation, Inc.
@@ -345,9 +345,10 @@
                type = libdm_table_get_target(table);
                params = libdm_table_get_params(table);
 
-               if (params != NULL)
-                       plen = strlen(params) + 1;
+               if (params == NULL)
+                       params = "";
 
+               plen = strlen(params) + 1;
                rec_size = sizeof(struct dm_target_spec) + plen;
 
                /*
@@ -357,17 +358,17 @@
                 */
                next += rec_size;
 
-               if (rec_size > dmi->data_size)
+               if (rec_size > dmi->data_size) {
+                       libdm_table_destroy(table);
+                       libdm_iter_destroy(iter);
                        return -ENOMEM;
+               }
 
                dmts->next = next;
                strlcpy(dmts->target_type, type, DM_MAX_TYPE_NAME);
                params_start = (char *)dmts + sizeof(struct dm_target_spec);
 
-               if (params != NULL)
-                       strlcpy(params_start, params, plen);
-               else
-                       params_start = "\0";
+               strlcpy(params_start, params, plen);
 
                odmts = dmts;
                dmts = (struct dm_target_spec *)((uint8_t *)dmts + rec_size);



Home | Main Index | Thread Index | Old Index