if (argv[i][keylen] != '=')
continue;
key_value= argv[i]+keylen+1;
- if (strlen(key_value)+1 > EP_BUF_SIZE)
+ if (strlen(key_value)+1 > max_len)
return(E2BIG);
strcpy(value, key_value);
return OK;
if ((key_value = find_key(mon_params, key)) == NULL)
return(ESRCH);
- /* Value found, make the actual copy (as far as possible). */
- strncpy(value, key_value, max_len);
-
- /* See if it fits in the client's buffer. */
+ /* Value found, see if it fits in the client's buffer. Callers assume that
+ * their buffer is unchanged on error, so don't make a partial copy.
+ */
if ((strlen(key_value)+1) > max_len) return(E2BIG);
+
+ /* Make the actual copy. */
+ strcpy(value, key_value);
+
return(OK);
}
int s;
if ((s=env_get_param(key, value, sizeof(value))) == 0) {
if (s != ESRCH) /* only error allowed */
- printf("WARNING: get_mon_param() failed in env_panic(): %d\n", s);
+ printf("WARNING: env_get_param() failed in env_panic(): %d\n", s);
}
printf("Bad environment setting: '%s = %s'\n", key, value);
panic("","", NO_NUM);
if ((s=env_get_param(env, value, sizeof(value))) != 0) {
if (s == ESRCH) return(EP_UNSET); /* only error allowed */
- printf("WARNING: get_mon_param() failed in env_parse(): %d\n",s);
+ printf("WARNING: env_get_param() failed in env_parse(): %d\n",s);
return(EP_EGETKENV);
}
val = value;
if ((s = env_get_param(env, value, sizeof(value))) != 0) {
if (s != ESRCH) /* only error allowed */
- printf("WARNING: get_mon_param() failed in env_prefix(): %d\n", s);
+ printf("WARNING: env_get_param() failed in env_prefix(): %d\n", s);
+ return FALSE;
}
n = strlen(prefix);
- return(value != NULL
- && strncmp(value, prefix, n) == 0
+ return(strncmp(value, prefix, n) == 0
&& strchr(punct, value[n]) != NULL);
}