]> git.ipfire.org Git - thirdparty/squid.git/blobdiff - src/auth/ntlm/SMB_LM/ntlm_smb_lm_auth.cc
Source Format Enforcement (#763)
[thirdparty/squid.git] / src / auth / ntlm / SMB_LM / ntlm_smb_lm_auth.cc
index edca1d2e165d9b2ae5a434d5e01993db675a6d45..7a38dc4d1b49cd6abf59b47a2eb8265c9641df3c 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 1996-2016 The Squid Software Foundation and contributors
+ * Copyright (C) 1996-2021 The Squid Software Foundation and contributors
  *
  * Squid software is distributed under GPLv2+ license and includes
  * contributions from numerous individuals and organizations.
@@ -157,7 +157,7 @@ init_challenge(char *domain, char *domain_controller)
         handle = NULL;
         return 2;
     }
-    if (handle->Security == 0) {    /* share-level security, unuseable */
+    if (handle->Security == 0) {    /* share-level security, unusable */
         debug("SMB Server uses share-level security .. we need user security.\n");
         SMB_Discon(handle, 0);
         handle = NULL;
@@ -172,7 +172,7 @@ init_challenge(char *domain, char *domain_controller)
 const char *
 make_challenge(char *domain, char *domain_controller)
 {
-    /* trying to circumvent some strange problem wih pointers in SMBLib */
+    /* trying to circumvent some strange problem with pointers in SMBLib */
     /* Ugly as hell, but the lib is going to be dropped... */
     strncpy(my_domain, domain, sizeof(my_domain)-1);
     my_domain[sizeof(my_domain)-1] = '\0';
@@ -195,7 +195,7 @@ make_challenge(char *domain, char *domain_controller)
     size_t len = sizeof(chal) - sizeof(chal.payload) + le16toh(chal.target.maxlen);
     // for lack of a good NTLM token size limit, allow up to what the helper input can be
     // validations later will expect to be limited to that size.
-    static uint8_t b64buf[HELPER_INPUT_BUFFER-10]; /* 10 for other line fields, delimiters and terminator */
+    static char b64buf[HELPER_INPUT_BUFFER-10]; /* 10 for other line fields, delimiters and terminator */
     if (base64_encode_len(len) < sizeof(b64buf)-1) {
         debug("base64 encoding of the token challenge will exceed %" PRIuSIZE " bytes", sizeof(b64buf));
         return NULL;
@@ -206,7 +206,7 @@ make_challenge(char *domain, char *domain_controller)
     size_t blen = base64_encode_update(&ctx, b64buf, len, reinterpret_cast<const uint8_t *>(&chal));
     blen += base64_encode_final(&ctx, b64buf+blen);
     b64buf[blen] = '\0';
-    return reinterpret_cast<const char*>(b64buf);
+    return b64buf;
 }
 
 /* returns NULL on failure, or a pointer to
@@ -399,7 +399,7 @@ process_options(int argc, char *argv[])
         }
     }
     if (had_error)
-        exit(1);
+        exit(EXIT_FAILURE);
     /* Okay, now begin filling controllers up */
     /* we can avoid memcpy-ing, and just reuse argv[] */
     for (j = optind; j < argc; ++j) {
@@ -446,7 +446,7 @@ process_options(int argc, char *argv[])
     if (numcontrollers == 0) {
         fprintf(stderr, "You must specify at least one domain-controller!\n");
         usage();
-        exit(1);
+        exit(EXIT_FAILURE);
     }
     last_dc->next = controllers;    /* close the queue, now it's circular */
 }
@@ -503,7 +503,7 @@ manage_request()
     if (fgets(buf, NTLM_BLOB_BUFFER_SIZE, stdin) == NULL) {
         fprintf(stderr, "fgets() failed! dying..... errno=%d (%s)\n", errno,
                 strerror(errno));
-        exit(1);        /* BIIG buffer */
+        exit(EXIT_FAILURE);        /* BIIG buffer */
     }
     debug("managing request\n");
     ch2 = (char*)memchr(buf, '\n', NTLM_BLOB_BUFFER_SIZE);  /* safer against overrun than strchr */
@@ -518,7 +518,7 @@ manage_request()
         base64_decode_init(&ctx);
         size_t dstLen = 0;
         int decodedLen = 0;
-        if (!base64_decode_update(&ctx, &dstLen, reinterpret_cast<uint8_t*>(decoded), strlen(buf)-3, reinterpret_cast<const uint8_t*>(buf+3)) ||
+        if (!base64_decode_update(&ctx, &dstLen, reinterpret_cast<uint8_t*>(decoded), strlen(buf)-3, buf+3) ||
                 !base64_decode_final(&ctx)) {
             SEND("NA Packet format error, couldn't base64-decode");
             return;
@@ -567,7 +567,7 @@ manage_request()
                 }
                 /* there was an error. We have two errno's to look at.
                  * libntlmssp's erno is insufficient, we'll have to look at
-                 * the actual SMB library error codes, to acually figure
+                 * the actual SMB library error codes, to actually figure
                  * out what's happening. The thing has braindamaged interfacess..*/
                 smblib_err = SMB_Get_Last_Error();
                 smb_errorclass = SMBlib_Error_Class(SMB_Get_Last_SMB_Err());
@@ -693,6 +693,6 @@ main(int argc, char *argv[])
         manage_request();
     }
     /* notreached */
-    return 0;
+    return EXIT_SUCCESS;
 }