Imported Upstream version 7.53.1
[platform/upstream/curl.git] / tests / libtest / lib553.c
index 8694daf..288f4c1 100644 (file)
@@ -1,12 +1,26 @@
-/*****************************************************************************
+/***************************************************************************
  *                                  _   _ ____  _
  *  Project                     ___| | | |  _ \| |
  *                             / __| | | | |_) | |
  *                            | (__| |_| |  _ <| |___
  *                             \___|\___/|_| \_\_____|
  *
+ * Copyright (C) 1998 - 2016, Daniel Stenberg, <daniel@haxx.se>, et al.
  *
- * This test case and code is based on the bug recipe Joe Malicki provided for
+ * This software is licensed as described in the file COPYING, which
+ * you should have received as part of this distribution. The terms
+ * are also available at https://curl.haxx.se/docs/copyright.html.
+ *
+ * You may opt to use, copy, modify, merge, publish, distribute and/or sell
+ * copies of the Software, and permit persons to whom the Software is
+ * furnished to do so, under the terms of the COPYING file.
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
+ * KIND, either express or implied.
+ *
+ ***************************************************************************/
+
+/* This test case and code is based on the bug recipe Joe Malicki provided for
  * bug report #1871269, fixed on Jan 14 2008 before the 7.18.0 release.
  */
 
@@ -25,7 +39,7 @@ static size_t myreadfunc(void *ptr, size_t size, size_t nmemb, void *stream)
   memset(buf, 'A', sizeof(buf));
 
   size *= nmemb;
-  if (size > total)
+  if(size > total)
     size = total;
 
   if(size > sizeof(buf))
@@ -53,24 +67,25 @@ int test(char *URL)
     return TEST_ERR_MAJOR_BAD;
   }
 
-  if((curl = curl_easy_init()) == NULL) {
+  curl = curl_easy_init();
+  if(!curl) {
     fprintf(stderr, "curl_easy_init() failed\n");
     curl_global_cleanup();
     return TEST_ERR_MAJOR_BAD;
   }
 
-  for (i = 0; i < NUM_HEADERS; i++) {
-    int len = sprintf(buf, "Header%d: ", i);
+  for(i = 0; i < NUM_HEADERS; i++) {
+    int len = snprintf(buf, sizeof(buf), "Header%d: ", i);
     memset(&buf[len], 'A', SIZE_HEADERS);
     buf[len + SIZE_HEADERS]=0; /* zero terminate */
     hl = curl_slist_append(headerlist,  buf);
-    if (!hl)
+    if(!hl)
       goto test_cleanup;
     headerlist = hl;
   }
 
   hl = curl_slist_append(headerlist, "Expect: ");
-  if (!hl)
+  if(!hl)
     goto test_cleanup;
   headerlist = hl;