[Samba] Segment violation during the list of directory with smbc_readdir

Stanislav Tihohod tihohod at alarity.com
Tue Aug 21 09:30:27 GMT 2007


Dear samba,

I have a small piece of code that crashes on Samba 3.0.5:

int main()
{
    int smbdh;
    struct smbc_dirent *smbdi;
    char *smb_url = "smb://SERVER/Archive/NOT EMPTY";

    if(smbc_init(get_auth, 0) < 0)
    {
        fprintf(stderr, "error initializing libsmbclient: %s\n",
                        strerror(errno));
        return -1;
    }

    if((smbdh = smbc_opendir(smb_url)) < 1)
    {
        fprintf(stderr,"Unable to open directory: %s", strerror(errno));
        return -1;
    }

    while((smbdi = smbc_readdir(smbdh)) != NULL)
    {
        fprintf(stderr, "%s\n", smbdi->name);
    }

    printf("DONE\n");

    return 0;
}

The listed folder contains a file with a very long Japanese name.
The next call of smbc_readdir after this file is listed crashes:

.
..
New Text Document.txt
sdfsdf
Ц¬ґЦ-TЦ¦LИv-Ц¦?Ц--ХLЁЦ¬ґЦ-TЦ¦LИv-Ц¦?Ц--ХLЁЦ¬ґЦ-TЦ¦LИv-Ц¦?Ц--ХLЁЦ¬ґЦ-TЦ¦LИv-Ц¦?Ц--ХLЁЦ¬ґЦ-TЦ¦LИv-Ц¦?Ц--ХLЁЦ¬ґЦ-TЦ¦LИv-Ц¦?Ц--ХLЁЦ¬ґЦ-TЦ¦LИv-Ц¦?Ц--ХLЁЦ¬ґЦ-TЦ¦LИv-Ц¦?Ц--ХLЁЦ¬ґЦ-TЦ¦LИv-Ц¦?Ц--ХLЁЦ¬ґЦ-TЦ¦LИv-Ц¦?Ц--ХLЁЦ¬ґЦ-TЦ¦LИv-Ц¦?Ц--ХLЁЦ¬ґЦ-TЦ¦LИv-Ц¦?Ц--ХLЁЦ¬ґЦ-TЦ¦LИv-Ц¦?Ц--ХLЁЦ¬ґЦ-TЦ¦LИv-Ц¦?Ц--ХLЁЦ¬ґЦ-TЦ¦LИv-Ц¦?Ц--ХLЁЦ¬ґЦ-TЦ¦LИv-Ц¦?Ц--ХLЁЦ¬ґЦ-TЦ¦LИv-Ц¦?Ц--ХLЁЦ¬ґЦ-TЦ¦LИv-Ц¦?Ц--ХLЁЦ¬ґЦ-TЦ¦LИv-Ц¦?Ц--ХLЁЦ¬ґЦ-TЦ¦LИv-Ц¦?Ц--ХLЁЦ¬ґЦ-TЦ¦LИv-Ц¦?Ц--ХLЁЦ¬ґЦ-TЦ¦LИv-Ц¦?Ц--ХLЁЦ¬ґЦ-TЦ¦LИv-Ц¦?Ц--ХLЁЦ¬ґЦ-TЦ¦LИv-Ц¦?Ц--ХLЁЦ¬ґЦ-TЦ¦LИv-Ц¦?Ц--ХLЁЦ¬ґЦ-TЦ¦LИv-Ц¦?Ц--ХLЁЦ¬ґЦ-TЦ¦LИv-Ц¦?Ц--ХLЁЦ¬ґЦ-TЦ¦LИv-Ц¦?Ц--ХLЁ
Segmentation fault

I have updated samba to 3.0.25b and now my sample does not crash.

Is it a fixed bug in the old Samba? I could not find any records
about fixing of smbc_readdir in the WHATSNEW.txt file.

Thank you.

-- 
Best regards,
 Stanislav                          mailto:tihohod at alarity.com



More information about the samba mailing list