]> arthur.barton.de Git - netatalk.git/commitdiff
fixes for papd authentication.
authordidg <didg>
Sat, 14 Feb 2004 02:47:15 +0000 (02:47 +0000)
committerdidg <didg>
Sat, 14 Feb 2004 02:47:15 +0000 (02:47 +0000)
etc/uams/uams_guest.c
etc/uams/uams_pam.c
etc/uams/uams_passwd.c

index 21d0d7698c7fbd412e5b83a3415c8d826961c90c..4dc0883ecedf52ec60bf8c2e59bb78bcfeefc2ee 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: uams_guest.c,v 1.12.6.1 2004-01-10 08:01:36 bfernhomberg Exp $
+ * $Id: uams_guest.c,v 1.12.6.2 2004-02-14 02:47:15 didg Exp $
  *
  * (c) 2001 (see COPYING)
  */
@@ -33,6 +33,11 @@ char *strchr (), *strrchr ();
 
 #include <atalk/afp.h>
 #include <atalk/uam.h>
+#include <atalk/util.h>
+
+#ifndef MIN
+#define MIN(a,b) ((a) < (b) ? (a) : (b))
+#endif /* MIN */
 
 extern void append(void *, const char *, int);
 
@@ -90,7 +95,12 @@ int noauth_printer(start, stop, username, out)
     static const char *loginok = "0\r";
 
     data = (char *)malloc(stop - start + 1);
-    strncpy(data, start, stop - start + 1);
+    if (!data) {
+       LOG(log_info, logtype_uams,"Bad Login NoAuthUAM: malloc");
+       return(-1);
+    }
+
+    strlcpy(data, start, stop - start + 1);
 
     /* We are looking for the following format in data:
      * (username)
@@ -104,12 +114,12 @@ int noauth_printer(start, stop, username, out)
        return(-1);
     }
     p++;
-    if ((q = strchr(data, ')' )) == NULL) {
+    if ((q = strchr(p, ')' )) == NULL) {
        LOG(log_info, logtype_uams,"Bad Login NoAuthUAM: username not found in string");
        free(data);
        return(-1);
     }
-    strncpy(username, p, q - p);
+    memcpy(username, p,  MIN( UAM_USERNAMELEN, q - p ));
 
     /* Done copying username, clean up */
     free(data);
index 625f5afc49dc6068f35f65d22e34aac4d01dca3b..c44789ac68690d1aa3c2b8c81d071f14406af02b 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: uams_pam.c,v 1.15.2.1.2.4 2003-11-01 02:38:09 bfernhomberg Exp $
+ * $Id: uams_pam.c,v 1.15.2.1.2.5 2004-02-14 02:47:15 didg Exp $
  *
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * Copyright (c) 1999 Adrian Sun (asun@u.washington.edu) 
@@ -43,6 +43,7 @@ char *strchr (), *strrchr ();
 
 #include <atalk/afp.h>
 #include <atalk/uam.h>
+#include <atalk/util.h>
 
 #define PASSWDLEN 8
 
@@ -351,14 +352,13 @@ int pam_printer(start, stop, username, out)
     static const char *loginok = "0\r";
     struct passwd *pwd;
 
-    data = (char *)malloc(stop - start + 2);
+    data = (char *)malloc(stop - start + 1);
     if (!data) {
        LOG(log_info, logtype_uams,"Bad Login ClearTxtUAM: malloc");
        return(-1);
     }
 
-    strncpy(data, start, stop - start + 1);
-    data[stop - start + 2] = 0;
+    strlcpy(data, start, stop - start + 1);
 
     /* We are looking for the following format in data:
      * (username) (password)
@@ -378,8 +378,7 @@ int pam_printer(start, stop, username, out)
        free(data);
        return(-1);
     }
-    strncpy(username, p, MIN(UAM_USERNAMELEN, q - p) );
-    username[ UAM_USERNAMELEN +1] = '\0';
+    memcpy(username, p, MIN(UAM_USERNAMELEN, q - p) );
 
     /* Parse input for password in next () */
     p = q + 3;
@@ -388,8 +387,7 @@ int pam_printer(start, stop, username, out)
        free(data);
        return(-1);
     }
-    strncpy(password, p, MIN(PASSWDLEN, (q - p)) );
-    password[ PASSWDLEN + 1] = '\0';
+    memcpy(password, p, MIN(PASSWDLEN, (q - p)) );
 
     /* Done copying username and password, clean up */
     free(data);
index e9a5df05068015887f221fffbf8aa20b831af42a..dd0135dfba6621b6f4feb8142d3bd3f7bb48c924 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: uams_passwd.c,v 1.19.2.1.2.5 2004-01-10 08:01:36 bfernhomberg Exp $
+ * $Id: uams_passwd.c,v 1.19.2.1.2.6 2004-02-14 02:47:15 didg Exp $
  *
  * Copyright (c) 1990,1993 Regents of The University of Michigan.
  * Copyright (c) 1999 Adrian Sun (asun@u.washington.edu) 
@@ -48,6 +48,7 @@ char *strchr (), *strrchr ();
 #include <atalk/afp.h>
 #include <atalk/logger.h>
 #include <atalk/uam.h>
+#include <atalk/util.h>
 
 #define PASSWDLEN 8
 
@@ -276,13 +277,12 @@ struct papfile    *out;
     static const char *loginok = "0\r";
     int ulen;
 
-    data = (char *)malloc(stop - start + 2);
+    data = (char *)malloc(stop - start + 1);
     if (!data) {
        LOG(log_info, logtype_uams,"Bad Login ClearTxtUAM: malloc");
        return(-1);
     }
-    strncpy(data, start, stop - start + 1);
-    data[stop - start + 2] = 0;
+    strlcpy(data, start, stop - start + 1);
 
     /* We are looking for the following format in data:
      * (username) (password)
@@ -297,25 +297,21 @@ struct papfile    *out;
         return(-1);
     }
     p++;
-    if ((q = strstr(data, ") (" )) == NULL) {
+    if ((q = strstr(p, ") (" )) == NULL) {
         LOG(log_info, logtype_uams,"Bad Login ClearTxtUAM: username not found in string");
         free(data);
         return(-1);
     }
-    strncpy(username, p, MIN( UAM_USERNAMELEN, (q - p)) );
-    username[ UAM_USERNAMELEN+1] = '\0';
-
+    memcpy(username, p,  MIN( UAM_USERNAMELEN, q - p ));
 
     /* Parse input for password in next () */
     p = q + 3;
-    if ((q = strrchr(data, ')' )) == NULL) {
+    if ((q = strrchr(, ')' )) == NULL) {
         LOG(log_info, logtype_uams,"Bad Login ClearTxtUAM: password not found in string");
         free(data);
         return(-1);
     }
-    strncpy(password, p, MIN(PASSWDLEN, q - p) );
-    password[ PASSWDLEN+1] = '\0';
-
+    memcpy(password, p, MIN(PASSWDLEN, q - p) );
 
     /* Done copying username and password, clean up */
     free(data);