# HG changeset patch # User masneyb # Date 1060309494 0 # Node ID 094e83b55cb10ff01102adcb1a82672e82177c9e # Parent 16a967a4d003aad1dc674197e002ece250f2f8dc 2003-8-7 Brian Masney * lib/cache.c lib/misc.c lib/protocols.c lib/pty.c - make sure a NUL byte appears at the end of the buffer after the call to strncpy * lib/rfc959.c - increased buffer size to directory parsing routine diff -r 16a967a4d003 -r 094e83b55cb1 ChangeLog --- a/ChangeLog Fri Aug 08 01:38:12 2003 +0000 +++ b/ChangeLog Fri Aug 08 02:24:54 2003 +0000 @@ -1,4 +1,9 @@ 2003-8-7 Brian Masney + * lib/cache.c lib/misc.c lib/protocols.c lib/pty.c - make sure a NUL + byte appears at the end of the buffer after the call to strncpy + + * lib/rfc959.c - increased buffer size to directory parsing routine + * lib/protocols.c (gftp_fd_write) - use a signed variable to store the result from write(). Write errors were not being caught properly. @@ -1442,7 +1447,7 @@ * cvsclean - added this script - * *.[ch] - added $Id: ChangeLog,v 1.129 2003/08/08 01:38:11 masneyb Exp $ tags + * *.[ch] - added $Id: ChangeLog,v 1.130 2003/08/08 02:24:53 masneyb Exp $ tags * debian/* - updated files from Debian maintainer diff -r 16a967a4d003 -r 094e83b55cb1 lib/cache.c --- a/lib/cache.c Fri Aug 08 01:38:12 2003 +0000 +++ b/lib/cache.c Fri Aug 08 02:24:54 2003 +0000 @@ -310,6 +310,7 @@ else if (descr != NULL) { strncpy (description, descr, sizeof (description)); + description[sizeof (description) - 1] = '\0'; } else return; diff -r 16a967a4d003 -r 094e83b55cb1 lib/misc.c --- a/lib/misc.c Fri Aug 08 01:38:12 2003 +0000 +++ b/lib/misc.c Fri Aug 08 02:24:54 2003 +0000 @@ -42,7 +42,10 @@ if (len == 0) { if (dest_str != NULL) - strncpy (dest_str, "0", dest_len); + { + strncpy (dest_str, "0", dest_len); + dest_str[dest_len - 1] = '\0'; + } else dest_str = g_strdup ("0"); return (dest_str); diff -r 16a967a4d003 -r 094e83b55cb1 lib/protocols.c --- a/lib/protocols.c Fri Aug 08 01:38:12 2003 +0000 +++ b/lib/protocols.c Fri Aug 08 02:24:54 2003 +0000 @@ -1996,7 +1996,7 @@ { *rbuf = g_malloc0 (sizeof (**rbuf)); (*rbuf)->max_bufsize = len; - (*rbuf)->buffer = g_malloc ((*rbuf)->max_bufsize + 1); + (*rbuf)->buffer = g_malloc0 ((*rbuf)->max_bufsize + 1); if ((ret = read_function (request, (*rbuf)->buffer, (*rbuf)->max_bufsize, fd)) <= 0) @@ -2019,21 +2019,25 @@ if ((*rbuf)->cur_bufsize > 0 && (pos != NULL || end_of_buffer)) { if (pos != NULL) - retval = pos - (*rbuf)->curpos + 1; - else - retval = (*rbuf)->cur_bufsize; - - if (pos != NULL) { + retval = pos - (*rbuf)->curpos + 1; nextpos = pos + 1; if (pos > (*rbuf)->curpos && *(pos - 1) == '\r') pos--; *pos = '\0'; } else - nextpos = NULL; + { + retval = (*rbuf)->cur_bufsize; + nextpos = NULL; + + /* This is not an overflow since we allocated one extra byte to + buffer above */ + ((*rbuf)->curpos)[retval] = '\0'; + } strncpy (str, (*rbuf)->curpos, len); + str[len - 1] = '\0'; (*rbuf)->cur_bufsize -= retval; if (nextpos != NULL) diff -r 16a967a4d003 -r 094e83b55cb1 lib/pty.c --- a/lib/pty.c Fri Aug 08 01:38:12 2003 +0000 +++ b/lib/pty.c Fri Aug 08 02:24:54 2003 +0000 @@ -40,6 +40,7 @@ return (GFTP_ERETRYABLE); strncpy (pts_name, new_pts_name, len); + pts_name[len - 1] = '\0'; return (fdm); } @@ -141,6 +142,7 @@ } strncpy (pts_name, new_pts_name, len); + pts_name[len - 1] = '\0'; return (fdm); } @@ -187,6 +189,8 @@ g_return_val_if_fail (len >= 10, GFTP_EFATAL); strncpy (pts_name, "/dev/ptyXY", len); + pts_name[len - 1] = '\0'; + for (pos1 = "pqrstuvwxyzPQRST"; *pos1 != '\0'; pos1++) { pts_name[8] = *pos1; diff -r 16a967a4d003 -r 094e83b55cb1 lib/rfc959.c --- a/lib/rfc959.c Fri Aug 08 01:38:12 2003 +0000 +++ b/lib/rfc959.c Fri Aug 08 02:24:54 2003 +0000 @@ -1385,7 +1385,7 @@ rfc959_get_next_file (gftp_request * request, gftp_file * fle, int fd) { rfc959_parms * parms; - char tempstr[255]; + char tempstr[1024]; ssize_t len; g_return_val_if_fail (request != NULL, GFTP_EFATAL);