static int nfsnprintf( char *buf, int blen, const char *fmt, ... );
+static int nfvasprintf(char **strp, const char *fmt, va_list ap)
+{
+ int len;
+ char tmp[8192];
+
+ len = vsnprintf(tmp, sizeof(tmp), fmt, ap);
+ if (len < 0)
+ die("Fatal: Out of memory\n");
+ if (len >= sizeof(tmp))
+ die("imap command overflow !\n");
+ *strp = xmemdupz(tmp, len);
+ return len;
+}
static void arc4_init( void );
static unsigned char arc4_getbyte( void );
goto bail;
cur->len = s - p;
s++;
- cur->val = xmalloc( cur->len + 1 );
- memcpy( cur->val, p, cur->len );
- cur->val[cur->len] = 0;
+ cur->val = xmemdupz(p, cur->len);
} else {
/* atom */
p = s;
if (level && *s == ')')
break;
cur->len = s - p;
- if (cur->len == 3 && !memcmp ("NIL", p, 3))
+ if (cur->len == 3 && !memcmp ("NIL", p, 3)) {
cur->val = NIL;
- else {
- cur->val = xmalloc( cur->len + 1 );
- memcpy( cur->val, p, cur->len );
- cur->val[cur->len] = 0;
+ } else {
+ cur->val = xmemdupz(p, cur->len);
}
}
} while (!feof(f));
msg->len = buf.len;
- msg->data = strbuf_detach(&buf);
+ msg->data = strbuf_detach(&buf, NULL);
return msg->len;
}
if (p)
msg->len = &p[1] - data;
- msg->data = xmalloc( msg->len + 1 );
- if (!msg->data)
- return 0;
-
- memcpy( msg->data, data, msg->len );
- msg->data[ msg->len ] = 0;
-
+ msg->data = xmemdupz(data, msg->len);
*ofs += msg->len;
return 1;
}
if (strncmp( key, imap_key, sizeof imap_key - 1 ))
return 0;
+
+ if (!val)
+ return config_error_nonbool(key);
+
key += sizeof imap_key - 1;
if (!strcmp( "folder", key )) {