summaryrefslogtreecommitdiffstats
path: root/mbbsd/record.c
diff options
context:
space:
mode:
authorpiaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2008-04-03 21:08:37 +0800
committerpiaip <piaip@63ad8ddf-47c3-0310-b6dd-a9e9d9715204>2008-04-03 21:08:37 +0800
commit09ad37923288982a63098a7aa346ea79748f7eca (patch)
treead0b24b51e730c1173f6a258e3aa0957f045c055 /mbbsd/record.c
parentec3ed850be27c29ecc4d9fc2a0f0404f997fc7d6 (diff)
downloadpttbbs-09ad37923288982a63098a7aa346ea79748f7eca.tar
pttbbs-09ad37923288982a63098a7aa346ea79748f7eca.tar.gz
pttbbs-09ad37923288982a63098a7aa346ea79748f7eca.tar.bz2
pttbbs-09ad37923288982a63098a7aa346ea79748f7eca.tar.lz
pttbbs-09ad37923288982a63098a7aa346ea79748f7eca.tar.xz
pttbbs-09ad37923288982a63098a7aa346ea79748f7eca.tar.zst
pttbbs-09ad37923288982a63098a7aa346ea79748f7eca.zip
- fix a 7-year bug? force_open should really "force" open file.
- (internal) code refine - drop MAXPATHLEN and change few magic number (256) to PATHLEN. git-svn-id: http://opensvn.csie.org/pttbbs/trunk/pttbbs@4072 63ad8ddf-47c3-0310-b6dd-a9e9d9715204
Diffstat (limited to 'mbbsd/record.c')
-rw-r--r--mbbsd/record.c17
1 files changed, 9 insertions, 8 deletions
diff --git a/mbbsd/record.c b/mbbsd/record.c
index d50df1d9..6b8a8af9 100644
--- a/mbbsd/record.c
+++ b/mbbsd/record.c
@@ -198,7 +198,7 @@ substitute_ref_record(const char *direct, fileheader_t * fhdr, int ent)
/* rocker.011022: 避免lock檔開啟時不正常斷線,造成永久lock */
#ifndef _BBS_UTIL_C_
-static int
+int
force_open(const char *fname)
{
int fd;
@@ -206,7 +206,7 @@ force_open(const char *fname)
expire = now - 3600; /* lock 存在超過一個小時就是有問題! */
- if (dasht(fname) < expire)
+ if (dasht(fname) > expire)
return -1;
unlink(fname);
fd = open(fname, O_WRONLY | O_TRUNC, 0644);
@@ -217,9 +217,9 @@ force_open(const char *fname)
/* new/old/lock file processing */
typedef struct nol_t {
- char newfn[256];
- char oldfn[256];
- char lockfn[256];
+ char newfn[PATHLEN];
+ char oldfn[PATHLEN];
+ char lockfn[PATHLEN];
} nol_t;
#ifndef _BBS_UTIL_C_
@@ -406,7 +406,7 @@ safe_article_delete_range(const char *direct, int from, int to)
strlcpy(fn, direct, sizeof(fn));
if( (ptr = rindex(fn, '/')) == NULL )
- return 0;
+ return -1;
++ptr;
if( (fd = open(direct, O_RDWR)) != -1 &&
@@ -428,8 +428,9 @@ safe_article_delete_range(const char *direct, int from, int to)
write(fd, &newfhdr, sizeof(fileheader_t));
}
close(fd);
+ return 0;
}
- return 0;
+ return -1;
}
@@ -634,7 +635,7 @@ setaidfile(char *buf, const char *bn, aidu_t aidu)
// try to load by AID
int bid = 0;
int n = 0, fd = 0;
- char bfpath[PATHLEN] = "";
+ char bfpath[PATHLEN];
boardheader_t *bh = NULL;
fileheader_t fh;