BSD 4_3 release
[unix-history] / usr / src / usr.lib / libU77 / link_.c
index ee072c6..dd0ee84 100644 (file)
@@ -1,6 +1,12 @@
 /*
 /*
-char id_link[] = "@(#)link_.c  1.1";
+ * Copyright (c) 1980 Regents of the University of California.
+ * All rights reserved.  The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
  *
  *
+ *     @(#)link_.c     5.1     6/7/85
+ */
+
+/*
  * make a link to an existing file
  *
  * calling sequence:
  * make a link to an existing file
  *
  * calling sequence:
@@ -12,19 +18,23 @@ char id_link[] = "@(#)link_.c       1.1";
  */
 
 #include "../libI77/f_errno.h"
  */
 
 #include "../libI77/f_errno.h"
+#include <sys/param.h>
+#ifndef        MAXPATHLEN
+#define MAXPATHLEN     128
+#endif
 
 long link_(name1, name2, n1len, n2len)
 char *name1, *name2;
 long n1len, n2len;
 {
 
 long link_(name1, name2, n1len, n2len)
 char *name1, *name2;
 long n1len, n2len;
 {
-       char buf1[128];
-       char buf2[128];
+       char buf1[MAXPATHLEN];
+       char buf2[MAXPATHLEN];
 
        if (n1len >= sizeof buf1 || n2len >= sizeof buf2)
                return((long)(errno=F_ERARG));
        g_char(name1, n1len, buf1);
        g_char(name2, n2len, buf2);
 
        if (n1len >= sizeof buf1 || n2len >= sizeof buf2)
                return((long)(errno=F_ERARG));
        g_char(name1, n1len, buf1);
        g_char(name2, n2len, buf2);
-       if (buf2[0] == '\0')
+       if (buf1[0] == '\0' || buf2[0] == '\0')
                return((long)(errno=F_ERARG));
        if (link(buf1, buf2) != 0)
                return((long)errno);
                return((long)(errno=F_ERARG));
        if (link(buf1, buf2) != 0)
                return((long)errno);