add: if (h == 1) { h = sizeof("\033[0m")-1; if (n+h < *len) { memcpy(cur, "\033[0m", h); n += h; cur += h; } else { goto overflow; } }
context: int xl_print_log(struct sip_msg* msg, xl_elog_p log, char *buf, int *len){	int n;	str tok;	xl_elog_p it;	char *cur;		if(msg==NULL || log==NULL || buf==NULL || len==NULL)		return -1;	if(*len <= 0)		return -1;	*buf = '\0';	cur = buf;		n = 0;	for (it=log; it; it=it->next)	{		/* put the text */		if(it->text.s && it->text.len>0)		{			if(n+it->text.len < *len)			{				memcpy(cur, it->text.s, it->text.len);				n += it->text.len;				cur += it->text.len;			}			else				goto overflow;		}		/* put the value of the specifier */		if(it->itf && !((*it->itf)(msg, &tok, &(it->hparam), it->hindex)))		{			if(n+tok.len < *len)			{				memcpy(cur, tok.s, tok.len);				n += tok.len;				cur += tok.len;			}			else				goto overflow;		}	}	goto done;	overflow:	LOG(L_ERR,		"XLOG:xl_print_log: buffer overflow -- increase the buffer size...\n");	return -1;done:	DBG("XLOG: xl_print_log: final buffer length %d\n", n);	*cur = '\0';	*len = n;	return 0;}