Subversion Repositories tpanel

Rev

Rev 401 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 401 Rev 406
Line 700... Line 700...
700
int ftplib::FtpAccess(const char *path, accesstype type, transfermode mode, ftphandle *nControl, ftphandle **nData)
700
int ftplib::FtpAccess(const char *path, accesstype type, transfermode mode, ftphandle *nControl, ftphandle **nData)
701
{
701
{
702
    char buf[256];
702
    char buf[256];
703
    int dir;
703
    int dir;
704
 
704
 
-
 
705
    memset(buf, 0, sizeof(buf));
-
 
706
 
705
    if ((path == NULL) && ((type == ftplib::filewrite)
707
    if ((path == NULL) && ((type == ftplib::filewrite)
706
                           || (type == ftplib::fileread)
708
                           || (type == ftplib::fileread)
707
                           || (type == ftplib::filereadappend)
709
                           || (type == ftplib::filereadappend)
708
                           || (type == ftplib::filewriteappend)))
710
                           || (type == ftplib::filewriteappend)))
709
    {
711
    {
Line 754... Line 756...
754
        buf[i++] = ' ';
756
        buf[i++] = ' ';
755
 
757
 
756
        if ((strlen(path) + i) >= sizeof(buf))
758
        if ((strlen(path) + i) >= sizeof(buf))
757
            return 0;
759
            return 0;
758
 
760
 
759
        strncpy(&buf[i], path, sizeof(buf));
761
        strncpy(&buf[i], path, sizeof(buf)-i);
760
    }
762
    }
761
 
763
 
762
    if (nControl->cmode == ftplib::pasv)
764
    if (nControl->cmode == ftplib::pasv)
763
    {
765
    {
764
        if (FtpOpenPasv(nControl, nData, mode, dir, buf) == -1)
766
        if (FtpOpenPasv(nControl, nData, mode, dir, buf) == -1)
Line 1285... Line 1287...
1285
 */
1287
 */
1286
 
1288
 
1287
int ftplib::Raw(const char *cmd)
1289
int ftplib::Raw(const char *cmd)
1288
{
1290
{
1289
    char buf[256];
1291
    char buf[256];
1290
    strncpy(buf, cmd, 256);
1292
    strncpy(buf, cmd, sizeof(buf));
1291
 
1293
 
1292
    if (!FtpSendCmd(buf, '2', mp_ftphandle))
1294
    if (!FtpSendCmd(buf, '2', mp_ftphandle))
1293
        return 0;
1295
        return 0;
1294
 
1296
 
1295
    return 1;
1297
    return 1;
Line 1761... Line 1763...
1761
            buf[i++] = ' ';
1763
            buf[i++] = ' ';
1762
 
1764
 
1763
            if ((strlen(pathSrc) + i) >= sizeof(buf))
1765
            if ((strlen(pathSrc) + i) >= sizeof(buf))
1764
                return 0;
1766
                return 0;
1765
 
1767
 
1766
            strncpy(&buf[i], pathSrc, sizeof(buf));
1768
            strncpy(&buf[i], pathSrc, sizeof(buf)-i);
1767
        }
1769
        }
1768
 
1770
 
1769
        if (!src->FtpSendCmd(buf, '1', src->mp_ftphandle))
1771
        if (!src->FtpSendCmd(buf, '1', src->mp_ftphandle))
1770
            return 0;
1772
            return 0;
1771
 
1773
 
Line 1779... Line 1781...
1779
            buf[i++] = ' ';
1781
            buf[i++] = ' ';
1780
 
1782
 
1781
            if ((strlen(pathDst) + i) >= sizeof(buf))
1783
            if ((strlen(pathDst) + i) >= sizeof(buf))
1782
                return 0;
1784
                return 0;
1783
 
1785
 
1784
            strncpy(&buf[i], pathDst, sizeof(buf));
1786
            strncpy(&buf[i], pathDst, sizeof(buf)-i);
1785
        }
1787
        }
1786
 
1788
 
1787
        if (!dst->FtpSendCmd(buf, '1', dst->mp_ftphandle))
1789
        if (!dst->FtpSendCmd(buf, '1', dst->mp_ftphandle))
1788
        {
1790
        {
1789
            /* this closes the data connection, to abort the RETR on
1791
            /* this closes the data connection, to abort the RETR on
Line 1835... Line 1837...
1835
            buf[i++] = ' ';
1837
            buf[i++] = ' ';
1836
 
1838
 
1837
            if ((strlen(pathDst) + i) >= sizeof(buf))
1839
            if ((strlen(pathDst) + i) >= sizeof(buf))
1838
                return 0;
1840
                return 0;
1839
 
1841
 
1840
            strncpy(&buf[i], pathDst, sizeof(buf));
1842
            strncpy(&buf[i], pathDst, sizeof(buf)-i);
1841
        }
1843
        }
1842
 
1844
 
1843
        if (!dst->FtpSendCmd(buf, '1', dst->mp_ftphandle))
1845
        if (!dst->FtpSendCmd(buf, '1', dst->mp_ftphandle))
1844
            return 0;
1846
            return 0;
1845
 
1847
 
Line 1853... Line 1855...
1853
            buf[i++] = ' ';
1855
            buf[i++] = ' ';
1854
 
1856
 
1855
            if ((strlen(pathSrc) + i) >= sizeof(buf))
1857
            if ((strlen(pathSrc) + i) >= sizeof(buf))
1856
                return 0;
1858
                return 0;
1857
 
1859
 
1858
            strncpy(&buf[i], pathSrc, sizeof(buf));
1860
            strncpy(&buf[i], pathSrc, sizeof(buf)-i);
1859
        }
1861
        }
1860
 
1862
 
1861
        if (!src->FtpSendCmd(buf, '1', src->mp_ftphandle))
1863
        if (!src->FtpSendCmd(buf, '1', src->mp_ftphandle))
1862
        {
1864
        {
1863
            src->FtpSendCmd("PASV", '2', src->mp_ftphandle);
1865
            src->FtpSendCmd("PASV", '2', src->mp_ftphandle);