* Copyright (C) 1995-2007, Index Data ApS
* See the file LICENSE for details.
*
- * $Id: unix.c,v 1.18 2007-01-03 08:42:15 adam Exp $
+ * $Id: unix.c,v 1.20 2007-10-09 06:00:56 adam Exp $
* UNIX socket COMSTACK. By Morten Bøgeskov.
*/
/**
int written; /* -1 if we aren't writing */
int towrite; /* to verify against user input */
- int (*complete)(const unsigned char *buf, int len); /* length/comple. */
+ int (*complete)(const char *buf, int len); /* length/complete. */
struct sockaddr_un addr; /* returned by cs_straddr */
int uid;
int gid;
return 0;
TRC(fprintf(stderr, "unix_strtoaddress: %s\n", str ? str : "NULL"));
add->sun_family = AF_UNIX;
- strncpy(add->sun_path, str, sizeof(add->sun_path));
+ strncpy(add->sun_path, str, sizeof(add->sun_path)-1);
+ add->sun_path[sizeof(add->sun_path)-1] = 0;
cp = strchr (add->sun_path, ':');
if (cp)
*cp = '\0';
{
unix_state *sp = (unix_state *)h->cprivate;
- return sp->altlen && (*sp->complete)((unsigned char *) sp->altbuf,
- sp->altlen);
+ return sp->altlen && (*sp->complete)(sp->altbuf, sp->altlen);
}
/*
return -1;
}
socket_unix.sun_family = AF_UNIX;
- strncpy(socket_unix.sun_path, path, sizeof(socket_unix.sun_path));
+ strncpy(socket_unix.sun_path, path, sizeof(socket_unix.sun_path)-1);
+ socket_unix.sun_path[sizeof(socket_unix.sun_path)-1] = 0;
if(connect(socket_out, (struct sockaddr *) &socket_unix, SUN_LEN(&socket_unix)) < 0) {
if(yaz_errno() == ECONNREFUSED) {
TRC (fprintf (stderr, "Socket exists but nobody is listening\n"));
sp->altsize = tmpi;
}
h->io_pending = 0;
- while (!(berlen = (*sp->complete)((unsigned char *)*buf, hasread)))
+ while (!(berlen = (*sp->complete)(*buf, hasread)))
{
if (!*bufsize)
{