]> git.sur5r.net Git - openldap/commitdiff
fix declarations of buffers for numeric strings; other related cleanup
authorPierangelo Masarati <ando@openldap.org>
Sat, 15 Dec 2007 15:23:23 +0000 (15:23 +0000)
committerPierangelo Masarati <ando@openldap.org>
Sat, 15 Dec 2007 15:23:23 +0000 (15:23 +0000)
21 files changed:
contrib/slapd-modules/smbk5pwd/smbk5pwd.c
include/ldap_pvt.h
libraries/libldap/url.c
libraries/liblutil/utils.c
servers/slapd/acl.c
servers/slapd/aclparse.c
servers/slapd/back-monitor/conn.c
servers/slapd/back-monitor/rww.c
servers/slapd/back-sql/add.c
servers/slapd/back-sql/config.c
servers/slapd/back-sql/proto-sql.h
servers/slapd/back-sql/schema-map.c
servers/slapd/back-sql/search.c
servers/slapd/back-sql/util.c
servers/slapd/config.h
servers/slapd/daemon.c
servers/slapd/overlays/dds.c
servers/slapd/proto-slap.h
servers/slapd/slap.h
servers/slapd/syncrepl.c
tests/progs/slapd-tester.c

index 564ca10fbe9db84029d19dd35fa1ce1657488586..78bc1daec6af6d251207a8f34171e1aa6b98166c 100644 (file)
@@ -532,9 +532,9 @@ static int smbk5pwd_exop_passwd(
                qpw->rs_mods = ml;
 
                keys = ch_malloc( 2 * sizeof(struct berval) );
-               keys[0].bv_val = ch_malloc( STRLENOF( "9223372036854775807L" ) + 1 );
+               keys[0].bv_val = ch_malloc( LDAP_PVT_INTTYPE_CHARS(long) );
                keys[0].bv_len = snprintf(keys[0].bv_val,
-                       STRLENOF( "9223372036854775807L" ) + 1,
+                       LDAP_PVT_INTTYPE_CHARS(long),
                        "%ld", slap_get_time());
                BER_BVZERO( &keys[1] );
                
@@ -554,9 +554,9 @@ static int smbk5pwd_exop_passwd(
                        qpw->rs_mods = ml;
 
                        keys = ch_malloc( 2 * sizeof(struct berval) );
-                       keys[0].bv_val = ch_malloc( STRLENOF( "9223372036854775807L" ) + 1 );
+                       keys[0].bv_val = ch_malloc( LDAP_PVT_INTTYPE_CHARS(long) );
                        keys[0].bv_len = snprintf(keys[0].bv_val,
-                                       STRLENOF( "9223372036854775807L" ) + 1,
+                                       LDAP_PVT_INTTYPE_CHARS(long),
                                        "%ld", slap_get_time() + pi->smb_must_change);
                        BER_BVZERO( &keys[1] );
 
@@ -577,9 +577,9 @@ static int smbk5pwd_exop_passwd(
                         qpw->rs_mods = ml;
 
                         keys = ch_malloc( 2 * sizeof(struct berval) );
-                        keys[0].bv_val = ch_malloc( STRLENOF( "9223372036854775807L" ) + 1 );
+                        keys[0].bv_val = ch_malloc( LDAP_PVT_INTTYPE_CHARS(long) );
                         keys[0].bv_len = snprintf(keys[0].bv_val,
-                                        STRLENOF( "9223372036854775807L" ) + 1,
+                                        LDAP_PVT_INTTYPE_CHARS(long),
                                         "%ld", slap_get_time() + pi->smb_can_change);
                         BER_BVZERO( &keys[1] );
 
index 1506983757700e2b67e7f658cd6340376fa1f57d..73eba3190ca43054b9a2c2095ce205c3ace5fea0 100644 (file)
@@ -169,7 +169,7 @@ LDAP_F( int ) ldap_bv2rdn_x LDAP_P((
        struct berval *, LDAPRDN *, char **, unsigned flags, void *ctx ));
 LDAP_F( int ) ldap_rdn2bv_x LDAP_P(( 
        LDAPRDN rdn, struct berval *bv, unsigned flags, void *ctx ));
-#endif
+#endif /* LDAP_AVA_NULL */
 
 /* url.c */
 LDAP_F (void) ldap_pvt_hex_unescape LDAP_P(( char *s ));
@@ -225,7 +225,7 @@ LDAP_F (void) ldap_pvt_sasl_remove LDAP_P(( struct sockbuf * ));
 
 #ifndef LDAP_PVT_SASL_LOCAL_SSF
 #define LDAP_PVT_SASL_LOCAL_SSF        71      /* SSF for Unix Domain Sockets */
-#endif
+#endif /* ! LDAP_PVT_SASL_LOCAL_SSF */
 
 struct ldap;
 struct ldapmsg;
@@ -316,6 +316,8 @@ LDAP_END_DECL
  * If none is available, unsigned long data is used.
  */
 
+LDAP_BEGIN_DECL
+
 #ifdef USE_MP_BIGNUM
 /*
  * Use OpenSSL's BIGNUM
@@ -404,4 +406,15 @@ typedef    unsigned long           ldap_pvt_mp_t;
 
 #include "ldap_pvt_uc.h"
 
+LDAP_END_DECL
+
+LDAP_BEGIN_DECL
+
+#include <limits.h>                            /* get CHAR_BIT */
+
+/* Buffer space for sign, decimal digits and \0. Note: log10(2) < 146/485. */
+#define LDAP_PVT_INTTYPE_CHARS(type) (((sizeof(type)*CHAR_BIT-1)*146)/485 + 3)
+
+LDAP_END_DECL
+
 #endif /* _LDAP_PVT_H */
index 6a6e076b56fa16c8a13a0b4f1f12a714639ffb6e..4ef41f5ef492874e0acfb408b9e727d1ec967cdd 100644 (file)
@@ -582,7 +582,7 @@ desc2str_len( LDAPURLDesc *u )
        len += sep;
 
        if ( u->lud_port ) {
-               char    buf[] = ":65535";
+               char    buf[ STRLENOF(":65535") + 1 ];
 
                len += snprintf( buf, sizeof( buf ), ":%d", u->lud_port );
                if ( u->lud_host && u->lud_host[0] ) {
index ff711da018fb530b48082a5a9b54a8d7d86938d5..0e1068653c3ab7313464772cf109a7ff6ca902c5 100644 (file)
@@ -17,6 +17,7 @@
 
 #include <stdio.h>
 #include <ac/stdlib.h>
+#include <ac/stdarg.h>
 #include <ac/string.h>
 #include <ac/ctype.h>
 #include <ac/unistd.h>
@@ -885,3 +886,53 @@ lutil_unparse_time(
        return 0;
 }
 
+/*
+ * formatted print to string
+ *
+ * - if return code < 0, the error code returned by vsnprintf(3) is returned
+ *
+ * - if return code > 0, the buffer was not long enough;
+ *     - if next is not NULL, *next will be set to buf + bufsize - 1
+ *     - if len is not NULL, *len will contain the required buffer length
+ *
+ * - if return code == 0, the buffer was long enough;
+ *     - if next is not NULL, *next will point to the end of the string printed so far
+ *     - if len is not NULL, *len will contain the length of the string printed so far 
+ */
+int
+lutil_snprintf( char *buf, ber_len_t bufsize, char **next, ber_len_t *len, LDAP_CONST char *fmt, ... )
+{
+       va_list         ap;
+       int             ret;
+
+       assert( buf != NULL );
+       assert( bufsize > 0 );
+       assert( fmt != NULL );
+
+       va_start( ap, fmt );
+       ret = vsnprintf( buf, bufsize, fmt, ap );
+       va_end( ap );
+
+       if ( ret < 0 ) {
+               return ret;
+       }
+
+       if ( len ) {
+               *len = ret;
+       }
+
+       if ( ret >= bufsize ) {
+               if ( next ) {
+                       *next = &buf[ bufsize - 1 ];
+               }
+
+               return 1;
+       }
+
+       if ( next ) {
+               *next = &buf[ ret ];
+       }
+
+       return 0;
+}
+
index a2b5d6f44be65914c7ec3eff4a5ce8fa96e65c7b..0ff7b389285128b55f62221d31ded5e8f89a3928 100644 (file)
@@ -1280,7 +1280,7 @@ slap_acl_mask(
                                        /* extract IP and try exact match */
                                        } else if ( b->a_peername_style == ACL_STYLE_IP ) {
                                                char            *port;
-                                               char            buf[] = "255.255.255.255";
+                                               char            buf[STRLENOF("255.255.255.255") + 1];
                                                struct berval   ip;
                                                unsigned long   addr;
                                                int             port_number = -1;
@@ -1325,7 +1325,7 @@ slap_acl_mask(
                                        /* extract IPv6 and try exact match */
                                        } else if ( b->a_peername_style == ACL_STYLE_IPV6 ) {
                                                char            *port;
-                                               char            buf[] = "FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF";
+                                               char            buf[STRLENOF("FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF:FFFF") + 1];
                                                struct berval   ip;
                                                struct in6_addr addr;
                                                int             port_number = -1;
index 37db9afd7f80fbdbaf8fed5496b23ed83f823ab0..22d2388853bec99e0eda6f1dc2f89234ecb1bb80 100644 (file)
@@ -39,7 +39,7 @@
 #include "lutil.h"
 
 static const char style_base[] = "base";
-char *style_strings[] = {
+const char *style_strings[] = {
        "regex",
        "expand",
        "exact",
index aeaa61f52986e1e9c2f3ae6b90cfbae532e910c4..64406d4b298923bb480f69b9d2bcbb6a46ac9a1f 100644 (file)
@@ -236,7 +236,7 @@ monitor_subsys_conn_update(
 
        if ( n != -1 ) {
                Attribute       *a;
-               char            buf[] = "+9223372036854775807L";
+               char            buf[LDAP_PVT_INTTYPE_CHARS(long)];
                ber_len_t       len;
 
                a = attr_find( e->e_attrs, mi->mi_ad_monitorCounter );
index 652698889f7ce9d85984898ae45801711e646ff6..a99a1fd24345e6bd5eba68bece216e6791ca1487 100644 (file)
@@ -162,7 +162,7 @@ monitor_subsys_rww_update(
        struct berval   nrdn;
 
        Attribute       *a;
-       char            buf[] = "+9223372036854775807L";
+       char            buf[LDAP_PVT_INTTYPE_CHARS(long)];
        long            num = 0;
        ber_len_t       len;
 
index 501c8bfd9693e73f8891a3672448753e1b509b52..9c73cec37160461f67bb05eb693fdd36fbd5ab22 100644 (file)
@@ -794,7 +794,7 @@ backsql_add_attr(
                int             prc = LDAP_SUCCESS;
                /* first parameter #, parameter order */
                SQLUSMALLINT    pno, po;
-               char            logbuf[] = "val[18446744073709551615UL], id=18446744073709551615UL";
+               char            logbuf[ STRLENOF("val[], id=") + 2*LDAP_PVT_INTTYPE_CHARS(unsigned long)];
                
                /*
                 * Do not deal with the objectClass that is used
index db1170c884bc6b331ad1d65897ba13ca18de9eaf..d24be62c76d1e2d7b440f685b658f6905f7e29ff 100644 (file)
@@ -540,8 +540,8 @@ backsql_db_config(
                        0, 0 );
 
        } else if ( !strcasecmp( argv[ 0 ], "fetch_attrs" ) ) {
-               char    *str, *s, *next;
-               char    delimstr[] = ",";
+               char            *str, *s, *next;
+               const char      *delimstr = ",";
 
                if ( argc < 2 ) {
                        Debug( LDAP_DEBUG_TRACE,
@@ -761,10 +761,10 @@ create_baseObject(
                        "objectClass: extensibleObject\n"
                        "description: builtin baseObject for back-sql\n"
                        "description: all entries mapped "
-                       "in the \"ldap_entries\" table\n"
-                       "description: must have "
-                       "\"" BACKSQL_BASEOBJECT_IDSTR "\" "
-                       "in the \"parent\" column",
+                               "in table \"ldap_entries\" "
+                               "must have "
+                               "\"" BACKSQL_BASEOBJECT_IDSTR "\" "
+                               "in the \"parent\" column",
                        be->be_suffix[0].bv_val );
 
        bi->sql_baseObject = str2entry( buf );
index 3af14d5ee0c63cc463639ff158db184856473433..d9d01777ca2dd1c9d3e6e70d5fccfedb1e48ceb2 100644 (file)
@@ -235,7 +235,7 @@ int backsql_free_db_conn( Operation *op, SQLHDBC dbh );
  * util.c
  */
 
-extern char 
+extern const char 
        backsql_def_oc_query[],
        backsql_def_needs_select_oc_query[],
        backsql_def_at_query[],
@@ -246,8 +246,7 @@ extern char
        backsql_def_subtree_cond[],
        backsql_def_upper_subtree_cond[],
        backsql_id_query[],
-       backsql_def_concat_func[];
-extern char 
+       backsql_def_concat_func[],
        backsql_check_dn_ru_query[];
 
 struct berbuf * backsql_strcat_x( struct berbuf *dest, void *memctx, ... );
index 98424c6aa9220b949f3d98e8205fe862129bf265..6959e07157da222904411f1e4f27d6df5bf93ed2 100644 (file)
@@ -189,7 +189,7 @@ static int
 backsql_add_sysmaps( backsql_info *bi, backsql_oc_map_rec *oc_map )
 {
        backsql_at_map_rec      *at_map;
-       char                    s[] = "+9223372036854775807L";
+       char                    s[LDAP_PVT_INTTYPE_CHARS(long)];
        struct berval           sbv;
        struct berbuf           bb;
        
@@ -228,13 +228,11 @@ backsql_add_sysmaps( backsql_info *bi, backsql_oc_map_rec *oc_map )
 
        at_map->bam_add_proc = NULL;
        {
-               char    tmp[] =
-                       "INSERT INTO ldap_entry_objclasses "
+               char    tmp[STRLENOF("INSERT INTO ldap_entry_objclasses "
                        "(entry_id,oc_name) VALUES "
                        "((SELECT id FROM ldap_entries "
-                       "WHERE oc_map_id="
-                       "18446744073709551615UL "       /* 64 bit ULONG */
-                       "AND keyval=?),?)";
+                       "WHERE oc_map_id= "
+                       "AND keyval=?),?)") + LDAP_PVT_INTTYPE_CHARS(unsigned long)];
                snprintf( tmp, sizeof(tmp), 
                        "INSERT INTO ldap_entry_objclasses "
                        "(entry_id,oc_name) VALUES "
@@ -246,12 +244,10 @@ backsql_add_sysmaps( backsql_info *bi, backsql_oc_map_rec *oc_map )
 
        at_map->bam_delete_proc = NULL;
        {
-               char    tmp[] =
-                       "DELETE FROM ldap_entry_objclasses "
+               char    tmp[STRLENOF("DELETE FROM ldap_entry_objclasses "
                        "WHERE entry_id=(SELECT id FROM ldap_entries "
-                       "WHERE oc_map_id="
-                       "18446744073709551615UL "       /* 64 bit ULONG */
-                       "AND keyval=?) AND oc_name=?";
+                       "WHERE oc_map_id= "
+                       "AND keyval=?) AND oc_name=?") + LDAP_PVT_INTTYPE_CHARS(unsigned long)];
                snprintf( tmp, sizeof(tmp), 
                        "DELETE FROM ldap_entry_objclasses "
                        "WHERE entry_id=(SELECT id FROM ldap_entries "
index 0da8590cd48b372cd13fdc8daad04b896d87f717..2437448055eaecc76c4ae1a2470444d4b186350d 100644 (file)
@@ -864,7 +864,7 @@ backsql_process_filter( backsql_srch_info *bsi, Filter *f )
                struct berval   keyval;
 #else /* ! BACKSQL_ARBITRARY_KEY */
                unsigned long   keyval;
-               char            keyvalbuf[] = "18446744073709551615";
+               char            keyvalbuf[LDAP_PVT_INTTYPE_CHARS(unsigned long)];
 #endif /* ! BACKSQL_ARBITRARY_KEY */
 
                switch ( f->f_choice ) {
index b3c319d5709ef041b7cb04a5807deef28fba95b8..6d323dc2b0ffd0957088a3fd8c9314ccd56bdc85 100644 (file)
 
 #define BACKSQL_STR_GROW 256
 
-char backsql_def_oc_query[] = 
+const char backsql_def_oc_query[] = 
        "SELECT id,name,keytbl,keycol,create_proc,delete_proc,expect_return "
        "FROM ldap_oc_mappings";
-char backsql_def_needs_select_oc_query[] = 
+const char backsql_def_needs_select_oc_query[] = 
        "SELECT id,name,keytbl,keycol,create_proc,create_keyval,delete_proc,"
        "expect_return FROM ldap_oc_mappings";
-char backsql_def_at_query[] = 
+const char backsql_def_at_query[] = 
        "SELECT name,sel_expr,from_tbls,join_where,add_proc,delete_proc,"
        "param_order,expect_return,sel_expr_u FROM ldap_attr_mappings "
        "WHERE oc_map_id=?";
-char backsql_def_delentry_stmt[] = "DELETE FROM ldap_entries WHERE id=?";
-char backsql_def_renentry_stmt[] =
+const char backsql_def_delentry_stmt[] = "DELETE FROM ldap_entries WHERE id=?";
+const char backsql_def_renentry_stmt[] =
        "UPDATE ldap_entries SET dn=?,parent=?,keyval=? WHERE id=?";
-char backsql_def_insentry_stmt[] = 
+const char backsql_def_insentry_stmt[] = 
        "INSERT INTO ldap_entries (dn,oc_map_id,parent,keyval) "
        "VALUES (?,?,?,?)";
-char backsql_def_delobjclasses_stmt[] = "DELETE FROM ldap_entry_objclasses "
+const char backsql_def_delobjclasses_stmt[] = "DELETE FROM ldap_entry_objclasses "
        "WHERE entry_id=?";
-char backsql_def_subtree_cond[] = "ldap_entries.dn LIKE CONCAT('%',?)";
-char backsql_def_upper_subtree_cond[] = "(ldap_entries.dn) LIKE CONCAT('%',?)";
-char backsql_id_query[] = "SELECT id,keyval,oc_map_id,dn FROM ldap_entries WHERE ";
+const char backsql_def_subtree_cond[] = "ldap_entries.dn LIKE CONCAT('%',?)";
+const char backsql_def_upper_subtree_cond[] = "(ldap_entries.dn) LIKE CONCAT('%',?)";
+const char backsql_id_query[] = "SELECT id,keyval,oc_map_id,dn FROM ldap_entries WHERE ";
 /* better ?||? or cast(?||? as varchar) */ 
-char backsql_def_concat_func[] = "CONCAT(?,?)";
+const char backsql_def_concat_func[] = "CONCAT(?,?)";
 
 /* TimesTen */
-char backsql_check_dn_ru_query[] = "SELECT dn_ru FROM ldap_entries";
+const char backsql_check_dn_ru_query[] = "SELECT dn_ru FROM ldap_entries";
 
 struct berbuf *
 backsql_strcat_x( struct berbuf *dest, void *memctx, ... )
index 3664adcb82086866ab10d7bfca0986ddbe6e3bdc..61b2dc65b193c166f0c4df6f8825876b5a7f9cce 100644 (file)
@@ -121,7 +121,7 @@ typedef struct config_args_s {
        char *tline;
        const char *fname;
        int lineno;
-       char log[MAXPATHLEN + STRLENOF(": line 18446744073709551615") + 1];
+       char log[MAXPATHLEN + STRLENOF(": line ") + LDAP_PVT_INTTYPE_CHARS(unsigned long)];
 #define cr_msg reply.msg
        ConfigReply reply;
        int depth;
index 21d0eae8c7f28f1398e4a0c630c288f80d44cad1..d68c4bd79ca1417f2790aea8ea7a536bee87461f 100644 (file)
@@ -1058,7 +1058,7 @@ get_url_perms(
                                                S_IRGRP, S_IWGRP, S_IXGRP,
                                                S_IROTH, S_IWOTH, S_IXOTH
                                        };
-                                       static char     c[] = "-rwxrwxrwx"; 
+                                       static const char       c[] = "-rwxrwxrwx"; 
 
                                        if ( value[ j ] == c[ j ] ) {
                                                p |= m[ j ];
index d21876e8b62a5440f0b9fe88d90fdd35d976f117..e55a6510c2f7f5ec6552250ae05998eca13aca61 100644 (file)
@@ -395,7 +395,7 @@ dds_op_add( Operation *op, SlapReply *rs )
        /* handle dynamic object operational attr(s) */
        if ( is_dynamicObject ) {
                time_t          ttl, expire;
-               char            ttlbuf[] = "31557600";
+               char            ttlbuf[STRLENOF("31557600") + 1];
                char            tsbuf[ LDAP_LUTIL_GENTIME_BUFSIZE ];
                struct berval   bv;
 
@@ -414,10 +414,12 @@ dds_op_add( Operation *op, SlapReply *rs )
 
                ttl = DDS_DEFAULT_TTL( di );
 
+               /* assert because should be checked at configure */
                assert( ttl <= DDS_RF2589_MAX_TTL );
 
                bv.bv_val = ttlbuf;
                bv.bv_len = snprintf( ttlbuf, sizeof( ttlbuf ), "%ld", ttl );
+               assert( bv.bv_len < sizeof( ttlbuf ) );
 
                /* FIXME: apparently, values in op->ora_e are malloc'ed
                 * on the thread's slab; works fine by chance,
@@ -1004,7 +1006,7 @@ dds_op_extended( Operation *op, SlapReply *rs )
                slap_callback   sc = { 0 };
                Modifications   ttlmod = { { 0 } };
                struct berval   ttlvalues[ 2 ];
-               char            ttlbuf[] = "31557600";
+               char            ttlbuf[STRLENOF("31557600") + 1];
 
                rs->sr_err = slap_parse_refresh( op->ore_reqdata, NULL, &ttl,
                        &rs->sr_text, NULL );
index 4e1684235a9d36700272278b4756cd42bc06b3d9..214bdf8944421b556f07b2bb0d4ea627521a25b8 100644 (file)
@@ -98,7 +98,7 @@ LDAP_SLAPD_F (int) acl_string_expand LDAP_P((
 /*
  * aclparse.c
  */
-LDAP_SLAPD_V (char *) style_strings[];
+LDAP_SLAPD_V (LDAP_CONST char *) style_strings[];
 
 LDAP_SLAPD_F (int) parse_acl LDAP_P(( Backend *be,
        const char *fname, int lineno,
@@ -2039,7 +2039,7 @@ LDAP_SLAPD_F (int) fe_access_allowed LDAP_P((
 
 # define UI2BVX(bv,ui,ctx) \
        do { \
-               char            buf[] = "+9223372036854775807L"; \
+               char            buf[LDAP_PVT_INTTYPE_CHARS(long)]; \
                ber_len_t       len; \
                len = snprintf( buf, sizeof( buf ), UI2BV_FORMAT, (ui) ); \
                if ( len > (bv)->bv_len ) { \
index 1ff340d2a63213762ecc37f599e3d176af04405d..20e2eb3ca611113346654edf0d4954785fed610a 100644 (file)
@@ -2446,7 +2446,7 @@ typedef struct Opheader {
 
        slap_counters_t *oh_counters;
 
-       char            oh_log_prefix[ /* sizeof("conn=18446744073709551615 op=18446744073709551615") */ SLAP_TEXT_BUFLEN ];
+       char            oh_log_prefix[ /* sizeof("conn= op=") + 2*LDAP_PVT_INTTYPE_CHARS(unsigned long) */ SLAP_TEXT_BUFLEN ];
 
 #ifdef LDAP_SLAPI
        void    *oh_extensions;         /* NS-SLAPI plugin */
index 2ba265a0f4f5ff603b334dfa2c5ef9a56090371e..1b48d28deb886d0506bfa20edeab7804b602c990 100644 (file)
@@ -3522,7 +3522,7 @@ parse_syncrepl_line(
                                si->si_anfile = attr_fname;
                        } else {
                                char *str, *s, *next;
-                               char delimstr[] = " ,\t";
+                               const char *delimstr = " ,\t";
                                str = ch_strdup( val );
                                for ( s = ldap_pvt_strtok( str, delimstr, &next );
                                                s != NULL;
index da488372a340cca6765742cedfa2940c88529e78..331eaac9cdd02c09be760f860e2e67005c2625f9 100644 (file)
@@ -140,7 +140,7 @@ main( int argc, char **argv )
        int             sextra_args = 0;
        char            scmd[MAXPATHLEN];
        /* static so that its address can be used in initializer below. */
-       static char     sloops[] = "18446744073709551615UL";
+       static char     sloops[LDAP_PVT_INTTYPE_CHARS(unsigned long)];
        /* read */
        char            *rfile = NULL;
        char            *rreqs[MAXREQS];
@@ -150,14 +150,14 @@ main( int argc, char **argv )
        int             ranum;
        int             rextra_args = 0;
        char            rcmd[MAXPATHLEN];
-       static char     rloops[] = "18446744073709551615UL";
+       static char     rloops[LDAP_PVT_INTTYPE_CHARS(unsigned long)];
        /* addel */
        char            *afiles[MAXREQS];
        int             anum = 0;
        char            *aargs[MAXARGS];
        int             aanum;
        char            acmd[MAXPATHLEN];
-       static char     aloops[] = "18446744073709551615UL";
+       static char     aloops[LDAP_PVT_INTTYPE_CHARS(unsigned long)];
        /* modrdn */
        char            *nfile = NULL;
        char            *nreqs[MAXREQS];
@@ -165,7 +165,7 @@ main( int argc, char **argv )
        char            *nargs[MAXARGS];
        int             nanum;
        char            ncmd[MAXPATHLEN];
-       static char     nloops[] = "18446744073709551615UL";
+       static char     nloops[LDAP_PVT_INTTYPE_CHARS(unsigned long)];
        /* modify */
        char            *mfile = NULL;
        char            *mreqs[MAXREQS];
@@ -174,7 +174,7 @@ main( int argc, char **argv )
        char            *margs[MAXARGS];
        int             manum;
        char            mcmd[MAXPATHLEN];
-       static char     mloops[] = "18446744073709551615UL";
+       static char     mloops[LDAP_PVT_INTTYPE_CHARS(unsigned long)];
        /* bind */
        char            *bfile = NULL;
        char            *breqs[MAXREQS];
@@ -184,7 +184,7 @@ main( int argc, char **argv )
        char            *bargs[MAXARGS];
        int             banum;
        char            bcmd[MAXPATHLEN];
-       static char     bloops[] = "18446744073709551615UL";
+       static char     bloops[LDAP_PVT_INTTYPE_CHARS(unsigned long)];
        char            **bargs_extra = NULL;
 
        char            *friendlyOpt = NULL;