char *ptr; /* Pointer to the location of the ':' (separator) */
int pos; /* Position of the ':' (separator) */
int len; /* Length of the string */
-
+
len = strlen(*fields);
/* Grab the separator's position */
key = emalloc(pos + 1);
val = emalloc((len - pos) + 1);
- strlcpy(key, *fields, pos);
- strlcpy(val, *fields + pos + 1, len - pos - 1);
+ strlcpy(key, *fields, pos + 1);
+ strlcpy(val, *fields + pos + 1, len - pos);
/* Check to see whether or not we want to save the data */
if (!strcmp(key, "msg")) {
else if (!strcmp(key, "line")) {
errline = estrdup(val);
}
-
+
/* Cleanup */
if (key) efree(key);
if (val) efree(val);
errline = estrndup("none", sizeof("none") - 1);
}
+ if (!errmsg) {
+ errmsg = estrndup("unkown error", sizeof("unkown error") - 1);
+ }
+
/* Allocate the message buffer and copy the data onto it */
msgbuf = emalloc((sizeof(msgformat) - 4) + strlen(errmsg) + strlen(errline) + 1);
sprintf(msgbuf, msgformat, errline, errmsg);