Commit af77c232 authored by Kurt Zeilenga's avatar Kurt Zeilenga
Browse files

Found the really, really stupid bug. The SAFEMEMCPY macro

in string.h was hosed for memmove/memcpy cases.
parent 44268993
......@@ -13,13 +13,13 @@
#include "portable.h"
#include <stdio.h>
#include <ctype.h>
#include <signal.h>
#include <ac/string.h>
#include <ac/time.h>
#include <ac/ctype.h>
#include <ac/signal.h>
#include <ac/socket.h>
#include <ac/string.h>
#include <ac/syslog.h>
#include <ac/time.h>
#include <ac/unistd.h>
#include <ac/wait.h>
......@@ -176,7 +176,7 @@ char **argv;
s = set_socket( port );
/* arrange to reap children */
(void) signal( SIGCHLD, (void *) wait4child );
(void) SIGNAL( SIGCHLD, wait4child );
} else {
myport = GO500_PORT;
......@@ -315,7 +315,7 @@ wait4child()
; /* NULL */
#endif
(void) signal( SIGCHLD, (void *) wait4child );
(void) SIGNAL( SIGCHLD, wait4child );
}
static
......
......@@ -13,13 +13,13 @@
#include "portable.h"
#include <stdio.h>
#include <ctype.h>
#include <signal.h>
#include <ac/time.h>
#include <ac/ctype.h>
#include <ac/signal.h>
#include <ac/socket.h>
#include <ac/string.h>
#include <ac/syslog.h>
#include <ac/time.h>
#include <ac/unistd.h>
#include <ac/wait.h>
......@@ -198,7 +198,7 @@ char **argv;
s = set_socket( port );
/* arrange to reap children */
(void) signal( SIGCHLD, (void *) wait4child );
(void) SIGNAL( SIGCHLD, wait4child );
}
if ( inetd ) {
......@@ -339,7 +339,7 @@ wait4child()
; /* NULL */
#endif
(void) signal( SIGCHLD, (void *) wait4child );
(void) SIGNAL( SIGCHLD, wait4child );
}
static do_queries( s )
......
......@@ -322,7 +322,7 @@ do_read( ldp, dn, reply, tmpll )
rc = ldap_entry2text_search( ldp, dn, searchbase, NULLMSG, tmpll,
defattrs, defvals, (void *)append_text, (void *)reply, "\n",
defattrs, defvals, append_text, (void *)reply, "\n",
rdncount, LDAP_DISP_OPT_DOSEARCHACTIONS );
return( rc );
......
......@@ -40,6 +40,8 @@ static int kinit();
static int valid_tgt();
#endif
static void set_bound_dn();
auth(who, implicit)
char *who;
int implicit;
......@@ -68,7 +70,6 @@ int implicit;
extern void printbase(); /* used to pretty-print a base */
extern int bind_status;
extern void Free();
static void set_bound_dn();
#ifdef DEBUG
if (debug & D_TRACE)
......
......@@ -33,6 +33,12 @@ extern LDAP *ld;
extern LDAPMessage *find();
static int load_editor();
static int modifiable();
static int print_attrs_and_values();
static int ovalues();
static int write_entry();
static char *entry_temp_file;
#ifdef DEBUG
......@@ -46,8 +52,6 @@ char *who;
char *dn, **rdns; /* distinguished name */
char name[MED_BUF_SIZE]; /* entry to modify */
extern int bind_status;
static int load_editor();
static int write_entry();
#ifdef DEBUG
if (debug & D_TRACE)
......@@ -114,7 +118,6 @@ static load_editor()
static char template[MED_BUF_SIZE];
extern char * mktemp();
extern int isgroup(), fatal();
static int print_attrs_and_values();
int pid;
int status;
int rc;
......@@ -195,7 +198,6 @@ FILE *fp;
struct attribute attrs[];
short flag;
{
static int modifiable();
register int i, j;
for (i = 0; attrs[i].quipu_name != NULL; i++) {
......@@ -242,7 +244,6 @@ static write_entry()
LDAPMod *mods[MAX_ATTRS + 1];
LDAPMod *modp = NULL;
static int ovalues();
extern char * code_to_str();
extern void free_mod_struct();
......
......@@ -37,6 +37,8 @@ extern LDAP *ld;
extern void Free();
static char * bind_and_fetch();
void add_group(name)
char *name;
{
......@@ -209,7 +211,6 @@ void remove_group(name)
char *name;
{
char *dn, tmp[BUFSIZ];
static char * bind_and_fetch();
#ifdef DEBUG
if (debug & D_TRACE) {
......@@ -260,7 +261,6 @@ char *name;
char *values[2], *group_name;
LDAPMod mod, *mods[2];
static char *actions[] = { "join", "resign from", NULL };
static char * bind_and_fetch();
#ifdef DEBUG
if (debug & D_TRACE) {
......
......@@ -27,6 +27,10 @@ extern int verbose;
extern LDAP *ld;
extern LDAPMessage *find();
extern void * Malloc();
static char * get_URL();
static int check_URL();
#ifdef DEBUG
extern int debug;
......@@ -382,9 +386,6 @@ char *id, *prompt;
static char line[LINE_SIZE]; /* raw line from user */
static char buffer[MAX_DESC_LINES * LINE_SIZE]; /* holds ALL of the
lines we get */
extern void * Malloc();
static char * get_URL();
#ifdef DEBUG
if (debug & D_TRACE)
printf("->get_value(%s, %s)\n", id, prompt);
......@@ -754,8 +755,6 @@ int group;
static char * get_URL()
{
char *rvalue, label[MED_BUF_SIZE], url[MED_BUF_SIZE];
static int check_URL();
extern void * Malloc();
if (verbose) {
printf(" First, enter the URL. (Example: http://www.us.itd.umich.edu/users/).\n");
......
......@@ -34,6 +34,9 @@ extern void * Malloc();
extern void Free();
extern char * my_ldap_dn2ufn();
static char *time2text();
static long gtime();
/*
* When displaying entries, display only these attributes, and in this
* order.
......@@ -193,7 +196,6 @@ print_an_entry()
char is_a_group, **order;
char *sub_list[MAX_VALUES], buf[SMALL_BUF_SIZE];
extern int col_size, isaurl(), isadn();
static char *time2text();
#ifdef DEBUG
if (debug & D_TRACE)
......@@ -557,7 +559,6 @@ time2text( char *ldtimestr, int dateonly )
struct tm t;
char *p, *timestr, zone, *fmterr = "badly formatted time";
time_t gmttime;
static long gtime();
memset( (char *)&t, 0, sizeof( struct tm ));
if ( strlen( ldtimestr ) < 13 ) {
......
......@@ -13,20 +13,22 @@
char *strchr (), *strrchr ();
# ifndef HAVE_MEMCPY
# define memcpy(d, s, n) bcopy ((s), (d), (n))
# define memmove(d, s, n) bcopy ((s), (d), (n))
# define memcpy(d, s, n) bcopy ((s), (d), (n))
# define memmove(d, s, n) bcopy ((s), (d), (n))
# endif
#endif
#if defined( HAVE_MEMMOVE )
#define SAFEMEMCPY( d, s, n ) memmove((s), (d), (n))
#elif defined( HAVE_BCOPY )
#define SAFEMEMCPY( d, s, n ) bcopy((s), (d), (n))
#elif defined( MACOS )
#define SAFEMEMCPY( d, s, n ) BlockMoveData((Ptr)(s), (Ptr)(d), (n))
#else
/* nothing left but memcpy() */
#define SAFEMEMCPY( d, s, n ) memcpy((s), (d), (n))
#ifndef SAFEMEMCPY
# if defined( HAVE_MEMMOVE )
# define SAFEMEMCPY( d, s, n ) memmove((d), (s), (n))
# elif defined( HAVE_BCOPY )
# define SAFEMEMCPY( d, s, n ) bcopy((s), (d), (n))
# elif defined( MACOS )
# define SAFEMEMCPY( d, s, n ) BlockMoveData((Ptr)(s), (Ptr)(d), (n))
# else
/* nothing left but memcpy() */
# define SAFEMEMCPY( d, s, n ) memcpy((d), (s), (n))
# endif
#endif
#endif /* _AC_STRING_H */
......@@ -49,4 +49,4 @@ LDAP_F char *ldap_SHA1Data
LDAP_END_DECL
#endif _LDAP_SHA1_H_
#endif /* _LDAP_SHA1_H_ */
......@@ -139,7 +139,7 @@ ldap_connect_to_host( Sockbuf *sb, char *host, unsigned long address,
#endif /* notyet */
Debug( LDAP_DEBUG_TRACE, "sd %d connected to: %s\n",
s, inet_ntoa( sin.sin_addr ), 0 );
s, (char *) inet_ntoa( sin.sin_addr ), 0 );
}
return( rc );
......
......@@ -79,7 +79,7 @@ ldap_sort_entries(
LDAP *ld,
LDAPMessage **chain,
char *attr, /* NULL => sort by DN */
int (*cmp)()
int (*cmp) LDAP_P((char *, char *))
)
{
int i, count;
......@@ -113,7 +113,7 @@ ldap_sort_entries(
last = e;
et_cmp_fn = cmp;
qsort( et, count, sizeof(struct entrything), (void *) et_cmp );
qsort( et, count, sizeof(struct entrything), et_cmp );
ep = chain;
for ( i = 0; i < count; i++ ) {
......@@ -140,7 +140,7 @@ ldap_sort_values(
for ( nel = 0; vals[nel] != NULL; nel++ )
; /* NULL */
qsort( vals, nel, sizeof(char *), (void *) cmp );
qsort( vals, nel, sizeof(char *), cmp );
return( 0 );
}
......@@ -63,7 +63,9 @@ crypted_value_find(
char *userpassword = vals[i]->bv_val + sizeof("{MD5}") - 1;
ldap_MD5Init(&MD5context);
ldap_MD5Update(&MD5context, cred->bv_val, strlen(cred->bv_val));
ldap_MD5Update(&MD5context,
(unsigned char *) cred->bv_val,
strlen(cred->bv_val));
ldap_MD5Final(MD5digest, &MD5context);
if (b64_ntop(MD5digest, sizeof(MD5digest),
......@@ -86,7 +88,9 @@ crypted_value_find(
char *userpassword = vals[i]->bv_val + sizeof("{SHA}") - 1;
ldap_SHA1Init(&SHA1context);
ldap_SHA1Update(&SHA1context, cred->bv_val, strlen(cred->bv_val));
ldap_SHA1Update(&SHA1context,
(unsigned char *) cred->bv_val,
strlen(cred->bv_val));
ldap_SHA1Final(SHA1digest, &SHA1context);
if (b64_ntop(SHA1digest, sizeof(SHA1digest),
......
......@@ -206,7 +206,7 @@ connection_activity(
* This is a draft 10 or standard pthreads implementation
*/
if ( pthread_create( &arg->co_op->o_tid, &attr,
(void *) connection_operation, (void *) arg ) != 0 ) {
connection_operation, (void *) arg ) != 0 ) {
Debug( LDAP_DEBUG_ANY, "pthread_create failed\n", 0, 0, 0 );
} else {
pthread_mutex_lock( &active_threads_mutex );
......@@ -218,7 +218,7 @@ connection_activity(
* This is a draft 4 or earlier pthreads implementation
*/
if ( pthread_create( &arg->co_op->o_tid, attr,
(void *) connection_operation, (void *) arg ) != 0 ) {
connection_operation, (void *) arg ) != 0 ) {
Debug( LDAP_DEBUG_ANY, "pthread_create failed\n", 0, 0, 0 );
} else {
pthread_mutex_lock( &active_threads_mutex );
......
......@@ -146,15 +146,15 @@ slapd_daemon(
* LinuxThreads are implemented using SIGUSR1/USR2,
* so we'll use SIGSTKFLT and SIGUNUSED
*/
(void) SIGNAL( SIGSTKFLT, (void *) do_nothing );
(void) SIGNAL( SIGUNUSED, (void *) set_shutdown );
(void) SIGNAL( SIGSTKFLT, do_nothing );
(void) SIGNAL( SIGUNUSED, set_shutdown );
#else /* !linux */
(void) SIGNAL( SIGUSR1, (void *) do_nothing );
(void) SIGNAL( SIGUSR2, (void *) set_shutdown );
(void) SIGNAL( SIGUSR1, do_nothing );
(void) SIGNAL( SIGUSR2, set_shutdown );
#endif /* !linux */
(void) SIGNAL( SIGTERM, (void *) set_shutdown );
(void) SIGNAL( SIGINT, (void *) set_shutdown );
(void) SIGNAL( SIGHUP, (void *) set_shutdown );
(void) SIGNAL( SIGTERM, set_shutdown );
(void) SIGNAL( SIGINT, set_shutdown );
(void) SIGNAL( SIGHUP, set_shutdown );
Debug( LDAP_DEBUG_ANY, "slapd starting\n", 0, 0, 0 );
#ifdef SLAPD_PIDFILE
......@@ -420,14 +420,14 @@ set_shutdown()
* so we'll use SIGSTKFLT and SIGUNUSED
*/
pthread_kill( listener_tid, SIGSTKFLT );
(void) SIGNAL( SIGUNUSED, (void *) set_shutdown );
(void) SIGNAL( SIGUNUSED, set_shutdown );
#else /* !linux */
pthread_kill( listener_tid, SIGUSR1 );
(void) SIGNAL( SIGUSR2, (void *) set_shutdown );
(void) SIGNAL( SIGUSR2, set_shutdown );
#endif /* !linux */
(void) SIGNAL( SIGTERM, (void *) set_shutdown );
(void) SIGNAL( SIGINT, (void *) set_shutdown );
(void) SIGNAL( SIGHUP, (void *) set_shutdown );
(void) SIGNAL( SIGTERM, set_shutdown );
(void) SIGNAL( SIGINT, set_shutdown );
(void) SIGNAL( SIGHUP, set_shutdown );
}
static void
......@@ -439,8 +439,8 @@ do_nothing()
* LinuxThreads are implemented using SIGUSR1/USR2,
* so we'll use SIGSTKFLT and SIGUNUSED
*/
(void) SIGNAL( SIGSTKFLT, (void *) do_nothing );
(void) SIGNAL( SIGSTKFLT, do_nothing );
#else /* !linux */
(void) SIGNAL( SIGUSR1, (void *) do_nothing );
(void) SIGNAL( SIGUSR1, do_nothing );
#endif /* !linux */
}
......@@ -185,7 +185,7 @@ main( argc, argv )
/* POSIX_THREADS or compatible
* This is a draft 10 or standard pthreads implementation
*/
if ( pthread_create( &listener_tid, &attr, (void *) slapd_daemon,
if ( pthread_create( &listener_tid, &attr, slapd_daemon,
(void *) port ) != 0 ) {
Debug( LDAP_DEBUG_ANY,
"listener pthread_create failed\n", 0, 0, 0 );
......@@ -195,7 +195,7 @@ main( argc, argv )
/*
* This is a draft 4 or earlier pthreads implementation
*/
if ( pthread_create( &listener_tid, attr, (void *) slapd_daemon,
if ( pthread_create( &listener_tid, attr, slapd_daemon,
(void *) port ) != 0 ) {
Debug( LDAP_DEBUG_ANY,
"listener pthread_create failed\n", 0, 0, 0 );
......
......@@ -474,7 +474,7 @@ get_idlist( fp, data )
p->b_nids = i;
}
qsort( (void *) p->b_ids, i, sizeof(ID), (void *) dnid_cmp );
qsort( (void *) p->b_ids, i, sizeof(ID), dnid_cmp );
}
data->dptr = (char *) p;
......
......@@ -35,9 +35,9 @@
* slurpd receives a USR2 signal, it will dump its replication
* queue to the disk file given by SLURPD_DUMPFILE.
*/
void
RETSIGTYPE
do_admin()
{
sglob->rq->rq_dump( sglob->rq );
(void) SIGNAL( SIGUSR2, (void *) do_admin );
(void) SIGNAL( SIGUSR2, do_admin );
}
......@@ -28,7 +28,7 @@
/*
* Externs
*/
extern void do_admin LDAP_P((void));
extern RETSIGTYPE do_admin LDAP_P((int));
extern int file_nonempty LDAP_P(( char * ));
extern int acquire_lock LDAP_P((char *, FILE **, FILE ** ));
extern int relinquish_lock LDAP_P((char *, FILE *, FILE * ));
......@@ -38,8 +38,8 @@ extern int relinquish_lock LDAP_P((char *, FILE *, FILE * ));
*/
static char *get_record LDAP_P(( FILE * ));
static void populate_queue LDAP_P(( char *f ));
static void set_shutdown LDAP_P((void));
void do_nothing LDAP_P((void));
static RETSIGTYPE set_shutdown LDAP_P((int));
RETSIGTYPE do_nothing LDAP_P((int));
/*
......@@ -64,15 +64,15 @@ fm(
* (not yet implemented).
*/
#ifdef HAVE_LINUX_THREADS
(void) SIGNAL( SIGSTKFLT, (void *) do_nothing );
(void) SIGNAL( SIGUNUSED, (void *) do_admin );
(void) SIGNAL( SIGSTKFLT, do_nothing );
(void) SIGNAL( SIGUNUSED, do_admin );
#else
(void) SIGNAL( SIGUSR1, (void *) do_nothing );
(void) SIGNAL( SIGUSR2, (void *) do_admin );
(void) SIGNAL( SIGUSR1, do_nothing );
(void) SIGNAL( SIGUSR2, do_admin );
#endif
(void) SIGNAL( SIGTERM, (void *) set_shutdown );
(void) SIGNAL( SIGINT, (void *) set_shutdown );
(void) SIGNAL( SIGHUP, (void *) set_shutdown );
(void) SIGNAL( SIGTERM, set_shutdown );
(void) SIGNAL( SIGINT, set_shutdown );
(void) SIGNAL( SIGHUP, set_shutdown );
if ( sglob->one_shot_mode ) {
if ( file_nonempty( sglob->slapd_replogfile )) {
......@@ -141,8 +141,8 @@ fm(
/*
* Set a global flag which signals that we're shutting down.
*/
static void
set_shutdown()
static RETSIGTYPE
set_shutdown(int x)
{
int i;
......@@ -158,9 +158,9 @@ set_shutdown()
(sglob->replicas[ i ])->ri_wake( sglob->replicas[ i ]);
}
sglob->rq->rq_unlock( sglob->rq ); /* unlock queue */
(void) SIGNAL( SIGTERM, (void *) set_shutdown ); /* reinstall handlers */
(void) SIGNAL( SIGINT, (void *) set_shutdown );
(void) SIGNAL( SIGHUP, (void *) set_shutdown );
(void) SIGNAL( SIGTERM, set_shutdown ); /* reinstall handlers */
(void) SIGNAL( SIGINT, set_shutdown );
(void) SIGNAL( SIGHUP, set_shutdown );
}
......@@ -169,13 +169,13 @@ set_shutdown()
/*
* A do-nothing signal handler.
*/
void
do_nothing()
RETSIGTYPE
do_nothing(int i)
{
#ifdef HAVE_LINUX_THREADS
(void) SIGNAL( SIGSTKFLT, (void *) do_nothing );
(void) SIGNAL( SIGSTKFLT, do_nothing );
#else
(void) SIGNAL( SIGUSR1, (void *) do_nothing );
(void) SIGNAL( SIGUSR1, do_nothing );
#endif
}
......
......@@ -128,7 +128,7 @@ main(
/* POSIX_THREADS or compatible
* This is a draft 10 or standard pthreads implementation
*/
if ( pthread_create( &(sglob->fm_tid), &attr, (void *) fm, (void *) NULL )
if ( pthread_create( &(sglob->fm_tid), &attr, fm, (void *) NULL )
!= 0 ) {
Debug( LDAP_DEBUG_ANY, "file manager pthread_create failed\n",
0, 0, 0 );
......@@ -139,7 +139,7 @@ main(
/*
* This is a draft 4 or earlier pthreads implementation
*/
if ( pthread_create( &(sglob->fm_tid), attr, (void *) fm, (void *) NULL )
if ( pthread_create( &(sglob->fm_tid), attr, fm, (void *) NULL )
!= 0 ) {
Debug( LDAP_DEBUG_ANY, "file manager pthread_create failed\n",
0, 0, 0 );
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment