commit 509a191474f9c872166d9345d0fd5c6b16cb36d8
Author: Oswald Buddenhagen <[email protected]>
Date: Thu Dec 29 14:34:30 2016 +0100
make more use of strnlen()
includes adding the so far superfluous prototype for the replacemnt to
common.h.
src/common.h | 3 +++
src/drv_imap.c | 5 ++---
2 files changed, 5 insertions(+), 3 deletions(-)
diff --git a/src/common.h b/src/common.h
index 00fc415..382794d 100644
--- a/src/common.h
+++ b/src/common.h
@@ -119,6 +119,9 @@ void free_string_list( string_list_t *list );
#ifndef HAVE_MEMRCHR
void *memrchr( const void *s, int c, size_t n );
#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_upper( const char *str, int strl, const char *cmp, int cmpl );
diff --git a/src/drv_imap.c b/src/drv_imap.c
index 328604f..656acd2 100644
--- a/src/drv_imap.c
+++ b/src/drv_imap.c
@@ -403,7 +403,7 @@ submit_imap_cmd( imap_store_t *ctx, struct imap_cmd *cmd )
static char *
imap_vprintf( const char *fmt, va_list ap )
{
- const char *s, *es;
+ const char *s;
char *d, *ed;
int maxlen;
char c;
@@ -454,8 +454,7 @@ imap_vprintf( const char *fmt, va_list ap )
*d++ = (char)va_arg( ap , int );
} else if (c == 's') {
s = va_arg( ap, const char * );
- es = memchr( s, 0, maxlen );
- l = es ? es - s : maxlen;
+ l = strnlen( s, maxlen );
if (d + l > ed)
oob();
memcpy( d, s, l );
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, SlashDot.org! http://sdm.link/slashdot
_______________________________________________
isync-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/isync-devel