Mercurial > gftp.yaz
diff lib/protocols.c @ 798:d59f62126c97
2006-8-8 Brian Masney <masneyb@gftp.org>
* lib/protocols.c (gftp_parse_ls_unix) - fixes whenever a smaller than
expected attribute field is returned (gftp_get_line) - make sure the
end of the buffer is nul terminated properly
| author | masneyb |
|---|---|
| date | Wed, 09 Aug 2006 00:31:06 +0000 |
| parents | 37bc51131e2d |
| children | 789ff8cb3170 |
line wrap: on
line diff
--- a/lib/protocols.c Mon Aug 07 20:54:15 2006 +0000 +++ b/lib/protocols.c Wed Aug 09 00:31:06 2006 +0000 @@ -1630,6 +1630,9 @@ if ((startpos = copy_token (&attribs, startpos)) == NULL) return (GFTP_EFATAL); + if (strlen (attribs) < 10) + return (GFTP_EFATAL); + fle->st_mode = gftp_convert_attributes_to_mode_t (attribs); g_free (attribs); @@ -2591,7 +2594,7 @@ /* This is not an overflow since we allocated one extra byte to buffer above */ - ((*rbuf)->curpos)[nslen] = '\0'; + ((*rbuf)->buffer)[nslen] = '\0'; } strncpy (str, (*rbuf)->curpos, len); @@ -2625,14 +2628,16 @@ if ((*rbuf)->eof) ret = 0; else - ret = read_function (request, pos, rlen, fd); - - if (ret < 0) { - gftp_free_getline_buffer (rbuf); - return (ret); + ret = read_function (request, pos, rlen, fd); + if (ret < 0) + { + gftp_free_getline_buffer (rbuf); + return (ret); + } } - else if (ret == 0) + + if (ret == 0) { if ((*rbuf)->cur_bufsize == 0) { @@ -2644,7 +2649,7 @@ } (*rbuf)->cur_bufsize += ret; - (*rbuf)->curpos[(*rbuf)->cur_bufsize] = '\0'; + (*rbuf)->buffer[(*rbuf)->cur_bufsize] = '\0'; } }
