if ((fd = smbc_getFunctionOpendir(ctx)(ctx, smb_path)) == NULL)
return NULL;
while((dirent = smbc_getFunctionReaddir(ctx)(ctx, fd)) != NULL){
+ size_t slen;
if (strcmp(dirent->name, "") == 0) continue;
if (strcmp(dirent->name, ".") == 0) continue;
if (strcmp(dirent->name, "..") == 0) continue;
- if ((item = malloc(sizeof(smbitem) + strlen(dirent->name))) == NULL)
+ slen = strlen(dirent->name)+1;
+ if ((item = malloc(sizeof(smbitem) + slen)) == NULL)
continue;
item->next = list;
item->type = dirent->smbc_type;
- strcpy(item->name, dirent->name);
+ memcpy(item->name, dirent->name, slen);
list = item;
}
smbc_getFunctionClose(ctx)(ctx, fd);
else print_smb_path(smb_group, list->name);
if (maxlen < 7 + strlen(list->name)) break;
- strcpy(smb_path + 6, list->name);
+ strncpy(smb_path + 6, list->name, maxlen - 6);
+ smb_path[maxlen-1] = '\0';
if ((ctx1 = create_smbctx()) != NULL){
recurse(ctx1, smb_group, smb_path, maxlen);
delete_smbctx(ctx1);
if (maxlen < len + strlen(list->name) + 2) break;
smb_path[len] = '/';
- strcpy(smb_path + len + 1, list->name);
+ strncpy(smb_path + len + 1, list->name, maxlen - len - 1);
+ smb_path[maxlen-1] = '\0';
print_smb_path(smb_group, smb_path + 6);
if (list->type != SMBC_FILE){
recurse(ctx, smb_group, smb_path, maxlen);
/* Now, write some date to the file ... */
memset(buff, '\0', sizeof(buff));
- strcpy(buff, "Some test data for the moment ...");
+ snprintf(buff, sizeof(buff), "%s", "Some test data for the moment ...");
err = smbc_write(fd, buff, sizeof(buff));