]> git.ipfire.org Git - thirdparty/squid.git/blobdiff - lib/smblib/find_password.c
SourceFormat Enforcement
[thirdparty/squid.git] / lib / smblib / find_password.c
index f31be07bd1b1fd795823d282f4ad7461d995840b..410ea6d819b30a07e1e167e692dfe53368ae9c22 100644 (file)
@@ -1,3 +1,12 @@
+/*
+ * Copyright (C) 1996-2015 The Squid Software Foundation and contributors
+ *
+ * Squid software is distributed under GPLv2+ license and includes
+ * contributions from numerous individuals and organizations.
+ * Please see the COPYING and CONTRIBUTORS files for details.
+ */
+
+#include "squid.h"
 /* Find passwords ... */
 /* We do it in a brute force way ... Cycle through all the possible passwords
    sending a logon to see if all it works ... We have to wait for any timeout
@@ -8,8 +17,11 @@
 
 #include <sys/types.h>
 #include <unistd.h>
+#if HAVE_STRING_H
+#include <string.h>
+#endif
 
-#include "smblib.h"
+#include "smblib/smblib.h"
 
 int verbose = FALSE;
 int lotc = FALSE;
@@ -43,7 +55,7 @@ int next_password(char *pw, int pwlen)
     if (pwinit == FALSE) {
 
         pwinit = TRUE;
-        bzero(pw, pwlen + 1);
+        memset(pw, 0, pwlen + 1);
         pwpos = 0;
 
     }
@@ -93,7 +105,7 @@ char *print_password(char * password)
         if (((unsigned)password[i] <= ' ') || ((unsigned)password[i] > 127)) {
 
             pwd_str[j] = '\\';
-            sprintf(temp, "%03i", (int)password[i]);
+            snprintf(temp, sizeof(temp)-1, "%03i", (int)password[i]);
             strcpy(&pwd_str[j + 1], temp);
             j = j + 3;                       /* Space for \ accounted for below */
 
@@ -224,11 +236,11 @@ main(int argc, char *argv[])
 
     }
 
-    sprintf(service_name, "\\\\%s\\%s", server, service); /* Could blow up */
+    sprintf(service_name, sizeof(service_name)-1, "\\\\%s\\%s", server, service); /* Could blow up */
 
     /* Now loop through all password possibilities ... */
 
-    bzero(password, sizeof(password));
+    memset(password, 0, sizeof(password));
 
     while (next_password(password, pwlen) == TRUE) {
 
@@ -276,3 +288,4 @@ main(int argc, char *argv[])
     fprintf(stderr, "Passwords exhausted.");
 
 }
+