Commit b42f9c4b authored by rswindell's avatar rswindell
Browse files

GLIBC's readdir() apparently doesn't handle NULL parameters very well. :-)

parent 1d9e6298
......@@ -617,7 +617,7 @@ void sbbs_t::batch_upload()
if(cfg.upload_dir==INVALID_DIR)
return;
dir=opendir(cfg.temp_dir);
while((dirent=readdir(dir))!=NULL) {
while(dir!=NULL && (dirent=readdir(dir))!=NULL) {
sprintf(str1,"%s%s",cfg.temp_dir,dirent->d_name);
if(isdir(str1))
continue;
......
......@@ -477,7 +477,7 @@ bool sbbs_t::pack_qwk(char *packet, ulong *msgcnt, bool prepack)
if(/*!prepack && */ useron.rest&FLAG('Q')) { /* If QWK Net node, check for files */
sprintf(str,"%sqnet/%s.out/",cfg.data_dir,useron.alias);
dir=opendir(str);
while((dirent=readdir(dir))!=NULL) { /* Move files into temp dir */
while(dir!=NULL && (dirent=readdir(dir))!=NULL) { /* Move files into temp dir */
sprintf(str,"%sqnet/%s.out/%s",cfg.data_dir,useron.alias,dirent->d_name);
if(isdir(str))
continue;
......@@ -606,7 +606,7 @@ bool sbbs_t::pack_qwk(char *packet, ulong *msgcnt, bool prepack)
if(useron.rest&FLAG('Q')) {
sprintf(str,"%s.qwk",cfg.sys_id);
dir=opendir(cfg.temp_dir);
while((dirent=readdir(dir))!=NULL) {
while(dir!=NULL && (dirent=readdir(dir))!=NULL) {
if(!stricmp(str,dirent->d_name)) /* QWK packet */
continue;
sprintf(tmp,"%s%s",cfg.temp_dir,dirent->d_name);
......
......@@ -201,7 +201,7 @@ bool sbbs_t::pack_rep(uint hubnum)
sprintf(str,"%sqnet/%s.out",cfg.data_dir,cfg.qhub[hubnum]->id);
strlwr(str);
dir=opendir(str);
while((dirent=readdir(dir))!=NULL) {
while(dir!=NULL && (dirent=readdir(dir))!=NULL) {
sprintf(str,"%sqnet/%s.out/%s",cfg.data_dir,cfg.qhub[hubnum]->id,dirent->d_name);
strlwr(str);
if(isdir(str))
......
......@@ -306,7 +306,7 @@ void sbbs_t::extract(uint dirnum)
if(fexist(str)) {
bputs(text[RemovingTempFiles]);
dir=opendir(cfg.temp_dir);
while((dirent=readdir(dir))!=NULL) {
while(dir!=NULL && (dirent=readdir(dir))!=NULL) {
sprintf(str,"%s%s",cfg.temp_dir,dirent->d_name);
if(!isdir(str))
remove(str);
......
......@@ -256,7 +256,7 @@ bool sbbs_t::unpack_qwk(char *packet,uint hubnum)
remove(str);
dir=opendir(cfg.temp_dir);
while((dirent=readdir(dir))!=NULL) {
while(dir!=NULL && (dirent=readdir(dir))!=NULL) {
// Create directory if necessary
sprintf(str,"%sqnet/%s.in",cfg.data_dir,cfg.qhub[hubnum]->id);
_mkdir(str);
......
......@@ -415,7 +415,7 @@ bool sbbs_t::unpack_rep(char* repfile)
remove(str);
dir=opendir(cfg.temp_dir);
while((dirent=readdir(dir))!=NULL) { /* Extra files */
while(dir!=NULL && (dirent=readdir(dir))!=NULL) { /* Extra files */
// Create directory if necessary
sprintf(str,"%sqnet/%s.in",cfg.data_dir,useron.alias);
_mkdir(str);
......
......@@ -532,7 +532,7 @@ bool sbbs_t::bulkupload(uint dirnum)
action=NODE_ULNG;
SYNC;
dir=opendir(path);
while((dirent=readdir(dir))!=NULL && !msgabort()) {
while(dir!=NULL && (dirent=readdir(dir))!=NULL && !msgabort()) {
if(getfiles(&cfg,dirnum)>=cfg.dir[dirnum]->maxfiles) {
bputs(text[DirFull]);
break;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment