VFS Linking errors
Jeremy Allison
jra at samba.org
Tue Oct 7 16:54:15 GMT 2008
On Tue, Oct 07, 2008 at 03:02:07PM +0100, Paul Weaver wrote:
> but C has the IP address of the client appended "msmMMOB.mdb.10.2.3.4"
>
> When you read the directory, you see "msmMMOB.mdb", but you see the copy
> of the file for your IP address.
>
> The code (roughly) is
> http://ingex.cvs.sourceforge.net/viewvc/ingex/ingex/MediaHarmony/media_h
> armony.c?revision=1.1&view=markup
>
> The specific troublesome line is
> static const char* MDB_FILENAME = "msmMMOB.mdb";
> fstrcpy(d->d_name, MDB_FILENAME);
>
> Sizeof MDB_FILENAME is 4, even though the content's 11 chars long, but I
> think that's ok
>
> Any hint as to what I could do better?
You can't just declare a SMB_STRUCT_DIRENT on
the stack and copy into it.
You have to allocate instead. Something like :
size_t len = strlen(MDB_FILENAME) + 1;
SMB_STRUCT_DIRENT *d = (SMB_STRUCT_DIRENT *)malloc(sizeof(SMB_STRUCT_DIRENT) + len);
strlcpy(d->d_name, MDB_FILENAME, len);
Jeremy.
More information about the samba-technical
mailing list