Git-Url:
http://git.frugalware.org/gitweb/gitweb.cgi?p=pacman-g2.git;a=commitdiff;h=08ba88e6f81b5537140e7853c81a4c8a6cfecd83
commit 08ba88e6f81b5537140e7853c81a4c8a6cfecd83
Author: Michel Hermier <[EMAIL PROTECTED]>
Date: Sun Sep 9 09:06:13 2007 +0200
ftplib: Don't use src == dest in some sprintf.
diff --git a/lib/libftp/ftplib.c b/lib/libftp/ftplib.c
index cbe3d70..f19d926 100644
--- a/lib/libftp/ftplib.c
+++ b/lib/libftp/ftplib.c
@@ -1517,23 +1517,30 @@ GLOBALREF int HttpGet(const char *host, const char
*outputfile, const char *path
int *size, netbuf *nControl, unsigned int offset,
const struct tm *mtime1, struct tm *mtime2)
{
- char buf[512];
+ char buf[512], tmp[512];
+
+ snprintf(buf, sizeof(buf), "GET %s HTTP/1.1\r\nHost: %s\r\n", path,
host);
- sprintf(buf, "GET %s HTTP/1.1\r\nHost: %s\r\n", path, host);
if (offset > 0)
- sprintf(buf, "%sRange: bytes=%d-\r\n", buf, offset);
+ {
+ snprintf(tmp, sizeof(tmp); "Range: bytes=%d-\r\n", offset);
+ strncat(buf, tmp, sizeof(buf)-strlen(buf)-1);
+ }
+
if (mtime1 && mtime1->tm_year)
{
char mtime[30];
/* Format:
* "If-Modified-Since: Sat, 29 Oct 1994 19:43:31 GMT\r\n" */
strftime(mtime, sizeof(mtime), "%a, %d %b %Y %H:%M:%S GMT", mtime1);
- sprintf(buf, "%sIf-Modified-Since: %s\r\n", buf, mtime);
+ snprintf(tmp, sizeof(tmp), "If-Modified-Since: %s\r\n", mtime);
+ strncat(buf, tmp, sizeof(buf)-strlen(buf)-1);
}
- if(strlen(buf)+3 > sizeof(buf))
+
+ strncat(buf, "\r\n", sizeof(buf));
+
+ if(strlen(buf) == sizeof(buf)-1)
return(0);
- else
- strcat(buf, "\r\n");
if (!HttpSendCmd(buf,'2',nControl))
{
_______________________________________________
Frugalware-git mailing list
[email protected]
http://frugalware.org/mailman/listinfo/frugalware-git