Browse Source

make more use of strnlen()

includes adding the so far superfluous prototype for the replacemnt to
common.h.
wip/uidval-recovery
Oswald Buddenhagen 8 years ago
parent
commit
509a191474
  1. 3
      src/common.h
  2. 5
      src/drv_imap.c

3
src/common.h

@ -119,6 +119,9 @@ void free_string_list( string_list_t *list );
#ifndef HAVE_MEMRCHR #ifndef HAVE_MEMRCHR
void *memrchr( const void *s, int c, size_t n ); void *memrchr( const void *s, int c, size_t n );
#endif #endif
#ifndef HAVE_STRNLEN
size_t strnlen( const char *str, size_t maxlen );
#endif
int starts_with( const char *str, int strl, const char *cmp, int cmpl ); int starts_with( const char *str, int strl, const char *cmp, int cmpl );
int starts_with_upper( const char *str, int strl, const char *cmp, int cmpl ); int starts_with_upper( const char *str, int strl, const char *cmp, int cmpl );

5
src/drv_imap.c

@ -403,7 +403,7 @@ submit_imap_cmd( imap_store_t *ctx, struct imap_cmd *cmd )
static char * static char *
imap_vprintf( const char *fmt, va_list ap ) imap_vprintf( const char *fmt, va_list ap )
{ {
const char *s, *es; const char *s;
char *d, *ed; char *d, *ed;
int maxlen; int maxlen;
char c; char c;
@ -454,8 +454,7 @@ imap_vprintf( const char *fmt, va_list ap )
*d++ = (char)va_arg( ap , int ); *d++ = (char)va_arg( ap , int );
} else if (c == 's') { } else if (c == 's') {
s = va_arg( ap, const char * ); s = va_arg( ap, const char * );
es = memchr( s, 0, maxlen ); l = strnlen( s, maxlen );
l = es ? es - s : maxlen;
if (d + l > ed) if (d + l > ed)
oob(); oob();
memcpy( d, s, l ); memcpy( d, s, l );

Loading…
Cancel
Save