--- libs3-4.1.orig/GNUmakefile
+++ libs3-4.1/GNUmakefile
@@ -43,6 +43,8 @@
 LIBS3_VER := $(LIBS3_VER_MAJOR).$(LIBS3_VER_MINOR)
 
 
+LIB=lib
+
 # -----------------------------------------------------------------------------
 # Determine verbosity.  VERBOSE_SHOW should be prepended to every command which
 # should only be displayed if VERBOSE is set.  QUIET_ECHO may be used to
@@ -91,7 +93,7 @@
 # --------------------------------------------------------------------------
 # LIBDIR directory
 ifndef LIBDIR
-    LIBDIR := ${DESTDIR}/lib
+    LIBDIR := ${DESTDIR}/${LIB}
 endif
 
 # --------------------------------------------------------------------------
@@ -130,13 +132,13 @@
 
 ifndef CFLAGS
     ifdef DEBUG
-        CFLAGS := -g
+        CFLAGS := $(RPM_OPT_FLAGS) -g
     else
-        CFLAGS := -O3
+        CFLAGS := $(RPM_OPT_FLAGS)
     endif
 endif
 
-CFLAGS += -Wall -Werror -Wshadow -Wextra -Iinc \
+CFLAGS += -Wall -Werror -Wshadow -Wextra -Wno-unused -Wno-sign-compare -Wformat-truncation=0 -Iinc \
           $(CURL_CFLAGS) $(LIBXML2_CFLAGS) \
           -DLIBS3_VER_MAJOR=\"$(LIBS3_VER_MAJOR)\" \
           -DLIBS3_VER_MINOR=\"$(LIBS3_VER_MINOR)\" \
@@ -198,10 +200,10 @@
 	$(VERBOSE_SHOW) \
 	    rm -f $(DESTDIR)/bin/s3 \
               $(DESTDIR)/include/libs3.h \
-              $(DESTDIR)/lib/libs3.a \
-              $(DESTDIR)/lib/libs3.so \
-              $(DESTDIR)/lib/libs3.so.$(LIBS3_VER_MAJOR) \
-              $(DESTDIR)/lib/libs3.so.$(LIBS3_VER)
+              $(DESTDIR)/$(LIB)/libs3.a \
+              $(DESTDIR)/$(LIB)/libs3.so \
+              $(DESTDIR)/$(LIB)/libs3.so.$(LIBS3_VER_MAJOR) \
+              $(DESTDIR)/$(LIB)/libs3.so.$(LIBS3_VER)
 
 
 # --------------------------------------------------------------------------
--- libs3-4.1.orig/debian/changelog
+++ libs3-4.1/debian/changelog
@@ -1,5 +1,39 @@
-libs3 (all) unstable; urgency=low
+libs3 (4.1-5) stable; urgency=low
 
-  * This file is not maintained.  See project source code for changes.
+  * fix-strops-lencheck.diff: fix len checking stringops that make
+    no sense (which the compiler duefully spotted).
+
+ -- Kurt Garloff <kurt@garloff.de>  Mon,  6 Jul 2020 07:47:38 +0200
+
+libs3 (4.1-4) stable; urgency=low
+
+  * fix-snprintf-overflow.diff: Apply on all modern distros. 
+
+ -- Kurt Garloff <kurt@garloff.de>  Mon,  6 Jul 2020 07:00:57 +0200
+
+libs3 (4.1-3) stable; urgency=low
+
+  * fix-duplicate-case.diff: CURLE_PEER_FAILE_VERIFICATION and 
+    CURLE_SSL_CACERT may be identical leading to compile errors.
+
+ -- Kurt Garloff <kurt@garloff.de>  Sun,  5 Jul 2020 08:22:58 +0200
+
+libs3 (4.1-2) stable; urgency=low
+
+  * Increase size of parts from 15 to 128MB. Display total number.
+
+ -- Kurt Garloff <kurt@garloff.de>  Fri,  5 May 2017 16:41:50 +0200
+
+libs3 (4.1-1) stable; urgency=low
+
+  * Update to github.com/bji.
+
+ -- Kurt Garloff <kurt@garloff.de>  Thu,  4 May 2017 19:43:28 +0200
+
+libs3 (2.0-1) stable; urgency=low
+
+  * Creation of deb package from libs3:
+    Include patch to rationalize put update progress output.
+
+ -- Kurt Garloff <kurt@garloff.de>  Fri, 26 Aug 2016 23:15:30 +0200
 
- -- Bryan Ischo <bryan@ischo.com>  Wed, 06 Aug 2008 09:36:43 -0400
--- libs3-4.1.orig/debian/compat
+++ libs3-4.1/debian/compat
@@ -0,0 +1 @@
+5
--- libs3-4.1.orig/debian/control
+++ libs3-4.1/debian/control
@@ -1,12 +1,38 @@
-Package: libs3
-Source: THIS LINE WILL BE REMOVED, dpkg-shlibdepends NEEDS IT
-Version: LIBS3_VERSION
-Architecture: DEBIAN_ARCHITECTURE
-Section: net
+Source: libs3
+Section: SystemUtilities
 Priority: extra
-Maintainer: Bryan Ischo <bryan@ischo.com>
-Homepage: https://github.com/bji/libs3
-Description: C Library and Tools for Amazon S3 Access
+Maintainer: Kurt Garloff <kurt@garloff.de>
+Homepage: http://sourceforge.net/projects/reallibs3
+Standards-Version: 3.9.4
+Build-Depends: debhelper (>=9), openssl, libssl-dev, libxml2-dev, libcurl4-openssl-dev
+
+Package: libs3-4
+Architecture: any
+Depends: ${shlibs:Depends}, ${misc:Depends}
+Description: 
  This package includes the libs3 shared object library, needed to run
  applications compiled against libs3, and additionally contains the s3
  utility for accessing Amazon S3.
+
+Package: libs3-dev
+Architecture: any
+Recommends: libs3-4 (= ${binary:Version})
+Depends: ${shlibs:Depends}, ${misc:Depends}
+Description: 
+ This library provides an API for using Amazon's S3 service (see
+ http://s3.amazonaws.com).  Its design goals are:
+ - To provide a simple and straightforward API for accessing all of S3's
+   functionality
+ - To not require the developer using libs3 to need to know anything about:
+     - HTTP
+     - XML
+     - SSL
+   In other words, this API is meant to stand on its own, without requiring
+   any implicit knowledge of how S3 services are accessed using HTTP
+   protocols.
+ - To be usable from multithreaded code
+ - To be usable by code which wants to process multiple S3 requests
+   simultaneously from a single thread
+ - To be usable in the simple, straightforward way using sequentialized
+   blocking requests
+
--- libs3-4.1.orig/debian/rules
+++ libs3-4.1/debian/rules
@@ -0,0 +1,112 @@
+#!/usr/bin/make -f
+# Sample debian/rules that uses debhelper.
+# This file is public domain software, originally written by Joey Hess. 
+#
+# This version is for packages that are architecture dependent.
+
+# Uncomment this to turn on verbose mode.
+#export DH_VERBOSE=1
+
+
+CFLAGS=$(shell dpkg-buildflags --get CFLAGS)
+LDFLAGS=$(shell dpkg-buildflags --get LDFLAGS)
+CFLAGS+=$(HARDENING_CFLAGS)
+LDFLAGS+=$(HARDENING_LDFLAGS)
+PKG=libs3-4
+LIBDESTDIR:=$(CURDIR)/debian/$(PKG)
+DEVDESTDIR:=$(CURDIR)/debian/libs3-dev
+
+#%:
+#	dh $@
+
+build: build-arch build-indep
+build-arch: build-stamp
+build-indep: build-stamp
+build-stamp:
+	dh_testdir
+
+	# Add here commands to compile the package.
+	#./autogen.sh
+	#./configure --enable-shared
+	$(MAKE) exported VERBOSE=1 RPM_OPT_FLAGS="${CFLAGS}" LIB=lib LIBDIR=/usr/lib
+	#$(MAKE) static
+	#$(MAKE) check
+
+	touch build-stamp
+
+clean:
+	dh_testdir
+	dh_testroot
+	rm -f build-stamp
+
+	# Add here commands to clean up after the build process.
+	$(MAKE) clean
+	#$(MAKE) distclean
+
+	dh_clean
+
+
+install: build
+	dh_testdir
+	dh_testroot
+	dh_prep
+	dh_installdirs
+
+	# Add here commands to install the package into debian/<packagename>
+	dh_listpackages
+	#$(MAKE) DESTDIR=`pwd`/debian/`dh_listpackages` PREFIX=/usr install
+	$(MAKE) DESTDIR=$(LIBDESTDIR)/usr PREFIX=/usr LIB=lib install
+	install -d $(LIBDESTDIR)/usr/share/doc/$(PKG)
+	install -m 0644 README COPYING ChangeLog TODO $(LIBDESTDIR)/usr/share/doc/$(PKG)/
+	# Move over devel files
+	mkdir -p $(DEVDESTDIR)/usr/lib/ $(DEVDESTDIR)/usr/include/
+	mv $(LIBDESTDIR)/usr/include/libs3.h $(DEVDESTDIR)/usr/include/
+	mv $(LIBDESTDIR)/usr/lib/libs3.a $(DEVDESTDIR)/usr/lib/
+	mv $(LIBDESTDIR)/usr/lib/libs3.so $(DEVDESTDIR)/usr/lib/
+
+	# HACK
+	sed -i 's/all/4.1-2/' debian/changelog
+
+
+# Build architecture-independent files here.
+binary-indep: build install
+# We have nothing to do by default.
+
+# Build architecture-dependent files here.
+binary-arch: build install
+	dh_testdir
+	dh_testroot
+	dh_installchangelogs
+	dh_installdocs
+	dh_installexamples
+#	dh_install
+#	dh_installmenu
+#	dh_installdebconf	
+#	dh_installlogrotate
+#	dh_installemacsen
+#	dh_installcatalogs
+#	dh_installpam
+#	dh_installmime
+#	dh_installinit
+#	dh_installcron
+#	dh_installinfo
+#	dh_installwm
+#	dh_installudev
+#	dh_lintian
+#	dh_bugfiles
+#	dh_undocumented
+	dh_installman
+	dh_link
+	dh_strip
+	dh_compress
+	dh_fixperms
+#	dh_perl
+	dh_makeshlibs
+	dh_installdeb
+	dh_shlibdeps
+	dh_gencontrol
+	dh_md5sums
+	dh_builddeb
+
+binary: binary-indep binary-arch
+.PHONY: build clean binary-indep binary-arch binary install
--- libs3-4.1.orig/src/request.c
+++ libs3-4.1/src/request.c
@@ -125,7 +125,7 @@
     char rangeHeader[128];
 
     // Authorization header
-    char authorizationHeader[1024];
+    char authorizationHeader[2688];
 
     // Request date stamp
     char requestDateISO8601[64];
@@ -822,7 +822,7 @@
     const char* params[numParams];
 
     char tokenized[strlen(queryString) + 1];
-    strncpy(tokenized, queryString, strlen(queryString) + 1);
+    strcpy(tokenized, queryString);
 
     char *tok = tokenized;
     const char *token = NULL;
@@ -863,10 +863,11 @@
             else {
                 snprintf(appendage, 4, "%%%02X", c);
             }
-            strncat(result, appendage, strlen(appendage));
+            strncat(result, appendage, 5); //strlen(appendage));
         }
-        strncat(result, "&", 1);
+        strcat(result, "&");
     }
+    // Really cut off last byte?
     result[strlen(result) - 1] = '\0';
 }
 
@@ -1456,7 +1457,7 @@
         userAgentInfo = "Unknown";
     }
 
-    char platform[96];
+    char platform[144];
     struct utsname utsn;
     if (uname(&utsn)) {
         snprintf(platform, sizeof(platform), "Unknown");
@@ -1711,7 +1712,9 @@
     case CURLE_PARTIAL_FILE:
         return S3StatusOK;
 #if LIBCURL_VERSION_NUM >= 0x071101 /* 7.17.1 */
+#if CURLE_PEER_FAILED_CERTIFICATION != CURLE_SSL_CACERT
     case CURLE_PEER_FAILED_VERIFICATION:
+#endif
 #else
     case CURLE_SSL_PEER_CERTIFICATE:
 #endif
--- libs3-4.1.orig/src/s3.c
+++ libs3-4.1/src/s3.c
@@ -2028,6 +2028,7 @@
         (put_object_callback_data *) callbackData;
 
     int ret = 0;
+    static int compl = -1;
 
     if (data->contentLength) {
         int toRead = ((data->contentLength > (unsigned) bufferSize) ?
@@ -2044,15 +2045,20 @@
     data->totalContentLength -= ret;
 
     if (data->contentLength && !data->noStatus) {
-        // Avoid a weird bug in MingW, which won't print the second integer
-        // value properly when it's in the same call, so print separately
-        printf("%llu bytes remaining ",
-               (unsigned long long) data->totalContentLength);
-        printf("(%d%% complete) ...\n",
-               (int) (((data->totalOriginalContentLength -
-                        data->totalContentLength) * 100) /
-                      data->totalOriginalContentLength));
+        int prcnt = ((data->originalContentLength - data->contentLength) * 200)
+                    / data->originalContentLength;
+        if (prcnt != compl) {
+            // Avoid a weird bug in MingW, which won't print the second integer
+            // value properly when it's in the same call, so print separately
+            printf("%llu bytes remaining ",
+                   (unsigned long long) data->contentLength);
+            printf("(%d%% complete) ... \r", prcnt/2);
+	    fflush(stdout);
+	    compl = prcnt;
+	}
     }
+    if (!data->contentLength)
+	    printf("\n");
 
     return ret;
 }
