summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan McDonald <danmcd@mnx.io>2022-12-06 11:07:59 -0500
committerDan McDonald <danmcd@mnx.io>2022-12-06 11:07:59 -0500
commit519ebb012f55b339005b58a1bd1735e4969abf7e (patch)
tree4d7ae40c23048dee7896b44868ca669b74ccf108
parent91d202bd4a855f8603d27f0cd32ed6d63525ff23 (diff)
parentd094b9b6950402cc8187f6a82d3d403d3892e7e7 (diff)
downloadillumos-joyent-519ebb012f55b339005b58a1bd1735e4969abf7e.tar.gz
[illumos-gate merge]
commit d094b9b6950402cc8187f6a82d3d403d3892e7e7 15201 bootadm list-menu segfaults for non-existent datasets commit eaf9751f5dce3a91368ffd99bccc978d5812e4fb 9293 bootadm: empty line between boot entries in menu.lst cause bootadm list-menu to segfault commit 0b49aa923f72d28badbed5f4d3ed43a816f07a39 15197 libdladm: enumeration values not handled in switch commit c8ed50c6d60fbb337f556eadef95cef18c28afa5 15193 libdladm: sizeof-pointer-memaccess commit 6fc1cd8d0240203842ead4a592ce7a8c4c3d65eb 15190 libofmt: comparison of integers of different signs
-rw-r--r--usr/src/cmd/boot/bootadm/bootadm_loader.c29
-rw-r--r--usr/src/lib/libdladm/Makefile.com1
-rw-r--r--usr/src/lib/libdladm/common/libdliptun.c2
-rw-r--r--usr/src/lib/libdladm/common/libdlsim.c2
-rw-r--r--usr/src/lib/libdladm/common/libdlvnic.c2
-rw-r--r--usr/src/lib/libofmt/common/ofmt.c14
6 files changed, 32 insertions, 18 deletions
diff --git a/usr/src/cmd/boot/bootadm/bootadm_loader.c b/usr/src/cmd/boot/bootadm/bootadm_loader.c
index e2d99b24b0..a9dde19132 100644
--- a/usr/src/cmd/boot/bootadm/bootadm_loader.c
+++ b/usr/src/cmd/boot/bootadm/bootadm_loader.c
@@ -325,29 +325,34 @@ menu_read(struct menu_lst *menu, char *menu_path)
ret = BAM_ERROR;
goto done;
}
+ if (buf[0] == '\n') /* Skip empty lines */
+ continue;
+
key = strtok(buf, " \n");
- if (strcmp(key, "title") != 0) {
+ if (key == NULL || strcmp(key, "title") != 0) {
ret = BAM_ERROR;
goto done;
}
value = strtok(NULL, " \n");
- if ((title = strdup(value)) == NULL) {
+ if (value == NULL || (title = strdup(value)) == NULL) {
ret = BAM_ERROR;
goto done;
}
- if (fgets(buf, PATH_MAX, fp) == NULL) {
- ret = BAM_ERROR;
- goto done;
- }
+ do {
+ if (fgets(buf, PATH_MAX, fp) == NULL) {
+ ret = BAM_ERROR;
+ goto done;
+ }
+ } while (buf[0] == '\n'); /* Skip empty lines */
key = strtok(buf, " \n");
- if ((type = strdup(key)) == NULL) {
+ if (key == NULL || (type = strdup(key)) == NULL) {
ret = BAM_ERROR;
goto done;
}
value = strtok(NULL, " \n");
- if ((bootfs = strdup(value)) == NULL) {
+ if (value == NULL || (bootfs = strdup(value)) == NULL) {
ret = BAM_ERROR;
goto done;
}
@@ -761,6 +766,11 @@ bam_mount_be(menu_entry_t *entry, char **dir)
if (strcmp(be_node->be_root_ds, entry->me_bootfs) == 0)
break;
+ if (be_node == NULL) {
+ ret = BE_ERR_BE_NOENT;
+ goto out;
+ }
+
if (nvlist_add_string(be_attrs, BE_ATTR_ORIG_BE_NAME,
be_node->be_node_name) != 0) {
ret = BE_ERR_NOMEM;
@@ -838,7 +848,8 @@ list_menu_entry(menu_entry_t *entry, char *setting)
(void) rmdir(dir);
free(dir);
}
- bam_error(_("%s is not mounted\n"), entry->me_title);
+ bam_error(_("%s is not mounted: %s\n"), entry->me_title,
+ be_err_to_str(mounted));
return (BAM_ERROR);
}
diff --git a/usr/src/lib/libdladm/Makefile.com b/usr/src/lib/libdladm/Makefile.com
index 0737012ec7..72f5a06d0f 100644
--- a/usr/src/lib/libdladm/Makefile.com
+++ b/usr/src/lib/libdladm/Makefile.com
@@ -44,7 +44,6 @@ SRCDIR = ../common
CFLAGS += $(CCVERBOSE)
CERRWARN += -_gcc=-Wno-parentheses
-CERRWARN += -_gcc=-Wno-switch
CERRWARN += -_gcc=-Wno-unused-label
CERRWARN += $(CNOWARN_UNINIT)
CPPFLAGS += -I$(SRCDIR) -D_REENTRANT
diff --git a/usr/src/lib/libdladm/common/libdliptun.c b/usr/src/lib/libdladm/common/libdliptun.c
index 8e4855fff5..cf1ab20ba3 100644
--- a/usr/src/lib/libdladm/common/libdliptun.c
+++ b/usr/src/lib/libdladm/common/libdliptun.c
@@ -122,6 +122,8 @@ i_iptun_kparams(dladm_handle_t handle, const iptun_params_t *params,
case IPTUN_TYPE_IPV6:
hints.ai_family = AF_INET6;
break;
+ case IPTUN_TYPE_UNKNOWN:
+ return (DLADM_STATUS_BADIPTUNLADDR);
}
}
diff --git a/usr/src/lib/libdladm/common/libdlsim.c b/usr/src/lib/libdladm/common/libdlsim.c
index 7b8c515875..c4d52abe60 100644
--- a/usr/src/lib/libdladm/common/libdlsim.c
+++ b/usr/src/lib/libdladm/common/libdlsim.c
@@ -386,7 +386,7 @@ dladm_simnet_info(dladm_handle_t handle, datalink_id_t simnet_id,
if (class != DATALINK_CLASS_SIMNET)
return (DLADM_STATUS_BADARG);
- bzero(attrp, sizeof (attrp));
+ bzero(attrp, sizeof (*attrp));
attrp->sna_link_id = simnet_id;
if (flags & DLADM_OPT_ACTIVE) {
diff --git a/usr/src/lib/libdladm/common/libdlvnic.c b/usr/src/lib/libdladm/common/libdlvnic.c
index 27e856006c..f5b754b66f 100644
--- a/usr/src/lib/libdladm/common/libdlvnic.c
+++ b/usr/src/lib/libdladm/common/libdlvnic.c
@@ -148,6 +148,8 @@ i_dladm_vnic_create_sys(dladm_handle_t handle, dladm_vnic_attr_t *attr)
bcopy(ioc.vc_mac_addr, attr->va_mac_addr, MAXMACADDRLEN);
attr->va_mac_len = ioc.vc_mac_len;
break;
+ default:
+ break;
}
return (status);
}
diff --git a/usr/src/lib/libofmt/common/ofmt.c b/usr/src/lib/libofmt/common/ofmt.c
index 0b248b2b2d..eb3624a8c2 100644
--- a/usr/src/lib/libofmt/common/ofmt.c
+++ b/usr/src/lib/libofmt/common/ofmt.c
@@ -71,7 +71,7 @@ typedef struct ofmt_state_s {
struct winsize os_winsize;
int os_nrow;
uint_t os_flags;
- int os_nbad;
+ uint_t os_nbad;
char **os_badfields;
int os_maxnamelen; /* longest name (f. multiline) */
char os_fs; /* field seperator */
@@ -141,7 +141,7 @@ static split_t *
split_fields(const ofmt_field_t *template, uint_t maxfields, uint_t maxcols)
{
split_t *sp;
- int i, cols;
+ uint_t i, cols;
sp = calloc(sizeof (split_t), 1);
if (sp == NULL)
@@ -311,7 +311,7 @@ void
ofmt_close(ofmt_handle_t ofmt)
{
ofmt_state_t *os = ofmt;
- int i;
+ uint_t i;
if (os == NULL)
return;
@@ -402,7 +402,7 @@ ofmt_fit_width(split_t **spp, uint_t width, char *value, uint_t bufsize)
{
split_t *sp = *spp;
char *ptr = value, *lim = ptr + bufsize;
- int i, nextlen;
+ uint_t i, nextlen;
if (sp == NULL) {
sp = split_str(value, OFMT_MAX_ROWS);
@@ -436,7 +436,7 @@ void
ofmt_print(ofmt_handle_t ofmt, void *arg)
{
ofmt_state_t *os = ofmt;
- int i;
+ uint_t i;
char value[1024];
ofmt_field_t *of;
boolean_t escsep, more_rows;
@@ -525,7 +525,7 @@ void
ofmt_print_header(ofmt_handle_t ofmt)
{
ofmt_state_t *os = ofmt;
- int i;
+ uint_t i;
ofmt_field_t *of = os->os_fields;
boolean_t escsep = (os->os_nfields > 1);
@@ -560,7 +560,7 @@ ofmt_strerror(ofmt_handle_t ofmt, ofmt_status_t error, char *buf,
uint_t bufsize)
{
ofmt_state_t *os = ofmt;
- int i;
+ uint_t i;
const char *s;
char ebuf[OFMT_BUFSIZE];
boolean_t parsable;