make more use of nfstrndup()
This commit is contained in:
parent
22145f6674
commit
3b615bba3c
|
@ -420,13 +420,8 @@ imap_vprintf( const char *fmt, va_list ap )
|
|||
oob();
|
||||
memcpy( d, s, l );
|
||||
d += l;
|
||||
if (!c) {
|
||||
l = d - buf;
|
||||
ed = nfmalloc( l + 1 );
|
||||
memcpy( ed, buf, l );
|
||||
ed[l] = 0;
|
||||
return ed;
|
||||
}
|
||||
if (!c)
|
||||
return nfstrndup( buf, d - buf );
|
||||
maxlen = INT_MAX;
|
||||
c = *++fmt;
|
||||
if (c == '\\') {
|
||||
|
@ -773,9 +768,7 @@ parse_imap_list( imap_store_t *ctx, char **sp, parse_list_state_t *sts )
|
|||
*d++ = c;
|
||||
}
|
||||
cur->len = d - p;
|
||||
cur->val = nfmalloc( cur->len + 1 );
|
||||
memcpy( cur->val, p, cur->len );
|
||||
cur->val[cur->len] = 0;
|
||||
cur->val = nfstrndup( p, cur->len );
|
||||
} else {
|
||||
/* atom */
|
||||
p = s;
|
||||
|
@ -785,11 +778,8 @@ parse_imap_list( imap_store_t *ctx, char **sp, parse_list_state_t *sts )
|
|||
cur->len = s - p;
|
||||
if (equals( p, cur->len, "NIL", 3 ))
|
||||
cur->val = NIL;
|
||||
else {
|
||||
cur->val = nfmalloc( cur->len + 1 );
|
||||
memcpy( cur->val, p, cur->len );
|
||||
cur->val[cur->len] = 0;
|
||||
}
|
||||
else
|
||||
cur->val = nfstrndup( p, cur->len );
|
||||
}
|
||||
|
||||
next:
|
||||
|
|
|
@ -1033,7 +1033,7 @@ maildir_scan( maildir_store_t *ctx, msg_t_array_alloc_t *msglist )
|
|||
fnl = (u ?
|
||||
nfsnprintf( buf + bl, sizeof(buf) - bl, "%s/%.*s,U=%d%s", subdirs[entry->recent], (int)(u - entry->base), entry->base, uid, ru ) :
|
||||
nfsnprintf( buf + bl, sizeof(buf) - bl, "%s/%s,U=%d", subdirs[entry->recent], entry->base, uid ))
|
||||
+ 1 - 4;
|
||||
- 4;
|
||||
memcpy( nbuf, buf, bl + 4 );
|
||||
nfsnprintf( nbuf + bl + 4, sizeof(nbuf) - bl - 4, "%s", entry->base );
|
||||
if (rename( nbuf, buf )) {
|
||||
|
@ -1048,8 +1048,7 @@ maildir_scan( maildir_store_t *ctx, msg_t_array_alloc_t *msglist )
|
|||
goto again;
|
||||
}
|
||||
free( entry->base );
|
||||
entry->base = nfmalloc( fnl );
|
||||
memcpy( entry->base, buf + bl + 4, fnl );
|
||||
entry->base = nfstrndup( buf + bl + 4, fnl );
|
||||
}
|
||||
if (ctx->gen.opts & OPEN_SIZE) {
|
||||
if (stat( buf, &st )) {
|
||||
|
@ -1571,8 +1570,7 @@ maildir_set_msg_flags( store_t *gctx, message_t *gmsg, int uid ATTR_UNUSED, int
|
|||
}
|
||||
}
|
||||
free( msg->base );
|
||||
msg->base = nfmalloc( tl + 1 );
|
||||
memcpy( msg->base, nbuf + bl, tl + 1 );
|
||||
msg->base = nfstrndup( nbuf + bl, tl );
|
||||
msg->gen.flags |= add;
|
||||
msg->gen.flags &= ~del;
|
||||
gmsg->status &= ~M_RECENT;
|
||||
|
|
Loading…
Reference in New Issue
Block a user