X-Git-Url: http://git.indexdata.com/?p=yaz-moved-to-github.git;a=blobdiff_plain;f=src%2Funix.c;h=5d6cad19cc88ed87c5d7020d89c8abc05c913421;hp=77cea3ce83253a38895dd45b3ad1c8382907d2e6;hb=1f41a1d415d2ab138050a96020ed39caa0c4e323;hpb=11dbebdf973d652e486f2b5e457cc46d1478556f diff --git a/src/unix.c b/src/unix.c index 77cea3c..5d6cad1 100644 --- a/src/unix.c +++ b/src/unix.c @@ -1,9 +1,6 @@ -/* - * Copyright (C) 1995-2005, Index Data ApS +/* This file is part of the YAZ toolkit. + * Copyright (C) 1995-2008 Index Data * See the file LICENSE for details. - * - * $Id: unix.c,v 1.17 2006-09-06 15:01:53 adam Exp $ - * UNIX socket COMSTACK. By Morten Bøgeskov. */ /** * \file unix.c @@ -90,7 +87,7 @@ typedef struct unix_state 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; @@ -185,7 +182,8 @@ static int unix_strtoaddr_ex(const char *str, struct sockaddr_un *add) 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'; @@ -308,8 +306,7 @@ static int unix_more(COMSTACK h) { 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); } /* @@ -405,7 +402,8 @@ static int unix_bind(COMSTACK h, void *address, int mode) 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")); @@ -573,7 +571,7 @@ static int unix_get(COMSTACK h, char **buf, int *bufsize) sp->altsize = tmpi; } h->io_pending = 0; - while (!(berlen = (*sp->complete)((unsigned char *)*buf, hasread))) + while (!(berlen = (*sp->complete)(*buf, hasread))) { if (!*bufsize) {