1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-27 03:21:53 +03:00

Fix two problems identified by the test suite, one a major one

where I was indexing through a NULL pointer :-(
(This used to be commit 5f1ea70e11)
This commit is contained in:
Richard Sharpe 2001-03-01 19:21:57 +00:00
parent ff2616aaf9
commit 1b476b12d9

View File

@ -667,9 +667,18 @@ ssize_t smbc_read(int fd, void *buf, size_t count)
}
/* Check that the buffer exists ... */
if (buf == NULL) {
errno = EINVAL;
return -1;
}
fe = smbc_file_table[fd - smbc_start_fd];
if (!fe->file) {
if (!fe || !fe->file) {
errno = EBADF;
return -1;
@ -727,6 +736,13 @@ ssize_t smbc_write(int fd, void *buf, size_t count)
fe = smbc_file_table[fd - smbc_start_fd];
if (!fe || !fe->file) {
errno = EBADF;
return -1;
}
ret = cli_write(&fe->srv->cli, fe->cli_fd, 0, buf, fe->offset, count);
if (ret <= 0) {
@ -765,6 +781,13 @@ int smbc_close(int fd)
fe = smbc_file_table[fd - smbc_start_fd];
if (!fe) {
errno = EBADF;
return -1;
}
if (!fe->file) {
return smbc_closedir(fd);
@ -967,6 +990,13 @@ off_t smbc_lseek(int fd, off_t offset, int whence)
fe = smbc_file_table[fd - smbc_start_fd];
if (!fe) {
errno = EBADF;
return -1;
}
if (!fe->file) {
return smbc_lseekdir(fd, offset, whence);
@ -1208,6 +1238,13 @@ int smbc_fstat(int fd, struct stat *st)
fe = smbc_file_table[fd - smbc_start_fd];
if (!fe) {
errno = EBADF;
return -1;
}
if (!fe->file) {
return smbc_fstatdir(fd, st);
@ -1620,7 +1657,7 @@ int smbc_opendir(const char *fname)
}
else {
errno = EINVAL;
errno = ENODEV; /* Neither the workgroup nor server exists */
if (smbc_file_table[slot]) free(smbc_file_table[slot]);
smbc_file_table[slot] = NULL;
return -1;
@ -1695,7 +1732,7 @@ int smbc_closedir(int fd)
if (!fe) {
errno = ENOENT; /* FIXME: Is this correct */
errno = EBADF;
return -1;
}
@ -1739,6 +1776,13 @@ struct smbc_dirent *smbc_readdir(unsigned int fd)
fe = smbc_file_table[fd - smbc_start_fd];
if (!fe) {
errno = EBADF;
return NULL;
}
if (fe->file != False) { /* FIXME, should be dir, perhaps */
errno = ENOTDIR;
@ -1802,6 +1846,13 @@ int smbc_getdents(unsigned int fd, struct smbc_dirent *dirp, int count)
fe = smbc_file_table[fd - smbc_start_fd];
if (!fe) {
errno = EBADF;
return -1;
}
if (fe->file != False) { /* FIXME, should be dir, perhaps */
errno = ENOTDIR;
@ -2027,6 +2078,13 @@ off_t smbc_telldir(int fd)
fe = smbc_file_table[fd - smbc_start_fd];
if (!fe) {
errno = EBADF;
return -1;
}
if (fe->file != False) { /* FIXME, should be dir, perhaps */
errno = ENOTDIR;