Fix leak for odr_print of ZOOM connection.
[yaz-moved-to-github.git] / src / unix.c
index 73bd7c5..5c3dce0 100644 (file)
@@ -1,9 +1,6 @@
-/*
- * Copyright (C) 1995-2007, Index Data ApS
+/* This file is part of the YAZ toolkit.
+ * Copyright (C) 1995-2009 Index Data
  * See the file LICENSE for details.
- *
- * $Id: unix.c,v 1.20 2007-10-09 06:00:56 adam Exp $
- * UNIX socket COMSTACK. By Morten Bøgeskov.
  */
 /**
  * \file unix.c
@@ -41,7 +38,7 @@
 #endif
 
 #include <yaz/unix.h>
-#include <yaz/nmem.h>
+#include <yaz/errno.h>
 
 #ifndef YAZ_SOCKLEN_T
 #define YAZ_SOCKLEN_T int
@@ -428,8 +425,16 @@ static int unix_bind(COMSTACK h, void *address, int mode)
         h->cerrno = CSYSERR;
         return -1;
     }
-    chown(path, sp->uid, sp->gid);
-    chmod(path, sp->umask != -1 ? sp->umask : 0666);
+    if (chown(path, sp->uid, sp->gid))
+    {
+        h->cerrno = CSYSERR;
+        return -1;
+    }
+    if (chmod(path, sp->umask != -1 ? sp->umask : 0666))
+    {
+        h->cerrno = CSYSERR;
+        return -1;
+    }
     if (mode == CS_SERVER && listen(h->iofile, 100) < 0)
     {
         h->cerrno = CSYSERR;
@@ -740,6 +745,7 @@ static int unix_set_blocking(COMSTACK p, int flags)
 /*
  * Local variables:
  * c-basic-offset: 4
+ * c-file-style: "Stroustrup"
  * indent-tabs-mode: nil
  * End:
  * vim: shiftwidth=4 tabstop=8 expandtab