summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCody Peter Mello <cody.mello@joyent.com>2016-03-04 01:00:10 +0000
committerCody Peter Mello <cody.mello@joyent.com>2016-03-18 18:12:57 +0000
commit868d62fdba8df95378d6e17a5b6154e3fd228de9 (patch)
treec150c6ff63442bea7c6c67913b9b38da719a049a
parent3c2b05cd7a3cf5ccaa4bc075821e355b2295c9f6 (diff)
downloadillumos-joyent-868d62fdba8df95378d6e17a5b6154e3fd228de9.tar.gz
OS-5215 zonecfg(1M) and dladm(1M) could support longer property values
Reviewed by: Joshua M. Clulow <jmc@joyent.com>
-rw-r--r--usr/src/cmd/zoneadmd/zoneadmd.c3
-rw-r--r--usr/src/cmd/zonecfg/Makefile1
-rw-r--r--usr/src/cmd/zonecfg/zonecfg.c25
-rw-r--r--usr/src/head/libzonecfg.h4
-rw-r--r--usr/src/lib/libdladm/common/libdladm.h2
5 files changed, 26 insertions, 9 deletions
diff --git a/usr/src/cmd/zoneadmd/zoneadmd.c b/usr/src/cmd/zoneadmd/zoneadmd.c
index ede1917d51..0a714fda38 100644
--- a/usr/src/cmd/zoneadmd/zoneadmd.c
+++ b/usr/src/cmd/zoneadmd/zoneadmd.c
@@ -765,7 +765,8 @@ static void
set_zonecfg_env(char *rsrc, char *attr, char *name, char *val)
{
char *p;
- char nm[MAXNAMELEN];
+ /* Enough for maximal name, rsrc + attr, & slop for ZONECFG & _'s */
+ char nm[2 * MAXNAMELEN + 32];
if (attr == NULL)
(void) snprintf(nm, sizeof (nm), "_ZONECFG_%s_%s", rsrc,
diff --git a/usr/src/cmd/zonecfg/Makefile b/usr/src/cmd/zonecfg/Makefile
index 94d725776b..e364a59679 100644
--- a/usr/src/cmd/zonecfg/Makefile
+++ b/usr/src/cmd/zonecfg/Makefile
@@ -38,6 +38,7 @@ MAPOPTS = $(MAPFILES:%=-M%)
LFLAGS = -t
YFLAGS = -d -b zonecfg_grammar
LDLIBS += -lzonecfg -ll -lnsl -ltecla -lzfs -lbrand -ldladm -linetutil -luuid
+CFLAGS += -DYYLMAX=2048
CPPFLAGS += -I.
LDFLAGS += $(MAPOPTS)
CLEANFILES += zonecfg_lex.c zonecfg_grammar.tab.c zonecfg_grammar.tab.h
diff --git a/usr/src/cmd/zonecfg/zonecfg.c b/usr/src/cmd/zonecfg/zonecfg.c
index 41423c95cd..8c318c547e 100644
--- a/usr/src/cmd/zonecfg/zonecfg.c
+++ b/usr/src/cmd/zonecfg/zonecfg.c
@@ -1000,7 +1000,8 @@ path_find(const char *name)
}
static FILE *
-pager_open(void) {
+pager_open(void)
+{
FILE *newfp;
char *pager, *space;
@@ -1026,7 +1027,8 @@ pager_open(void) {
}
static void
-pager_close(FILE *fp) {
+pager_close(FILE *fp)
+{
int status;
status = pclose(fp);
@@ -2467,8 +2469,13 @@ do_res_attr(struct zone_res_attrtab **headp, complex_property_ptr_t cpp)
pt_to_str(PT_NAME));
goto bad;
}
- (void) strlcpy(np->zone_res_attr_name, cp->cp_value,
- sizeof (np->zone_res_attr_name));
+ if (strlcpy(np->zone_res_attr_name, cp->cp_value,
+ sizeof (np->zone_res_attr_name)) >=
+ sizeof (np->zone_res_attr_name)) {
+ zerr(gettext("Input for %s is too long"),
+ pt_to_str(PT_NAME));
+ goto bad;
+ }
seen_name = B_TRUE;
break;
case PT_VALUE:
@@ -2477,8 +2484,14 @@ do_res_attr(struct zone_res_attrtab **headp, complex_property_ptr_t cpp)
pt_to_str(PT_VALUE));
goto bad;
}
- (void) strlcpy(np->zone_res_attr_value, cp->cp_value,
- sizeof (np->zone_res_attr_value));
+ if (strlcpy(np->zone_res_attr_value, cp->cp_value,
+ sizeof (np->zone_res_attr_value)) >=
+ sizeof (np->zone_res_attr_value)) {
+ zerr(gettext("Input for %s is too long"),
+ pt_to_str(PT_VALUE));
+ goto bad;
+ }
+
seen_value = B_TRUE;
break;
default:
diff --git a/usr/src/head/libzonecfg.h b/usr/src/head/libzonecfg.h
index 6adc07badc..b519a0cdcf 100644
--- a/usr/src/head/libzonecfg.h
+++ b/usr/src/head/libzonecfg.h
@@ -120,6 +120,8 @@ extern "C" {
#define ZONE_STATE_MAXSTRLEN 14
+#define ZONE_PROP_MAXSTRLEN 1024
+
#define LIBZONECFG_PATH "libzonecfg.so.1"
#define ZONE_CONFIG_ROOT "/etc/zones"
@@ -211,7 +213,7 @@ struct zone_fstab {
*/
struct zone_res_attrtab {
char zone_res_attr_name[MAXNAMELEN];
- char zone_res_attr_value[MAXNAMELEN];
+ char zone_res_attr_value[ZONE_PROP_MAXSTRLEN];
struct zone_res_attrtab *zone_res_attr_next;
};
diff --git a/usr/src/lib/libdladm/common/libdladm.h b/usr/src/lib/libdladm/common/libdladm.h
index 2a0491c048..e5da4e3b44 100644
--- a/usr/src/lib/libdladm/common/libdladm.h
+++ b/usr/src/lib/libdladm/common/libdladm.h
@@ -42,7 +42,7 @@ extern "C" {
#endif
#define LINKID_STR_WIDTH 10
-#define DLADM_STRSIZE 256
+#define DLADM_STRSIZE 2048
/*
* option flags taken by the libdladm functions