Imported Upstream version 7.50.2
[platform/upstream/curl.git] / tests / server / fake_ntlm.c
index 5b4d4fe..87118b3 100644 (file)
@@ -76,7 +76,7 @@ static char *printable(char *inbuf, size_t inlength)
     return NULL;
 
   if(!inlength) {
-    sprintf(&outbuf[0], "%s", NOTHING_STR);
+    snprintf(&outbuf[0], outsize, "%s", NOTHING_STR);
     return outbuf;
   }
 
@@ -98,7 +98,7 @@ static char *printable(char *inbuf, size_t inlength)
       o++;
     }
     else {
-      sprintf(&outbuf[o], HEX_FMT_STR, inbuf[i]);
+      snprintf(&outbuf[o], outsize - o, HEX_FMT_STR, inbuf[i]);
       o += HEX_STR_LEN;
     }
 
@@ -163,7 +163,7 @@ int main(int argc, char *argv[])
          (use_cached_creds) ? "yes" : "no");
 
   env = getenv("CURL_NTLM_AUTH_TESTNUM");
-  if (env) {
+  if(env) {
     char *endptr;
     long lnum = strtol(env, &endptr, 10);
     if((endptr != env + strlen(env)) || (lnum < 1L)) {
@@ -171,13 +171,14 @@ int main(int argc, char *argv[])
       exit(1);
     }
     testnum = lnum;
-  } else {
+  }
+  else {
     logmsg("Test number not specified in CURL_NTLM_AUTH_TESTNUM");
     exit(1);
   }
 
   env = getenv("CURL_NTLM_AUTH_SRCDIR");
-  if (env) {
+  if(env) {
     path = env;
   }
 
@@ -230,7 +231,8 @@ int main(int argc, char *argv[])
       }
       else {
         size = 0;
-        error = getpart(&type1_output, &size, "ntlm_auth_type1", "output", stream);
+        error = getpart(&type1_output, &size, "ntlm_auth_type1", "output",
+                        stream);
         fclose(stream);
         if(error || size == 0) {
           logmsg("getpart() type 1 output failed with error: %d", error);
@@ -251,7 +253,8 @@ int main(int argc, char *argv[])
       }
       else {
         size = 0;
-        error = getpart(&type3_output, &size, "ntlm_auth_type3", "output", stream);
+        error = getpart(&type3_output, &size, "ntlm_auth_type3", "output",
+                        stream);
         fclose(stream);
         if(error || size == 0) {
           logmsg("getpart() type 3 output failed with error: %d", error);