char *buf, *sfx;
} Pathbuf;
-#define MAX_SUFFIX 4
+#define MAX_SUFFIX 5
static void pathbuf_init(Pathbuf *pb, const char *pathb) {
int l= strlen(pathb);
- pb->buf= TALLOC(l + 4);
+ pb->buf= TALLOC(l + MAX_SUFFIX + 1);
memcpy(pb->buf, pathb, l);
pb->sfx= pb->buf + l;
- *pb->sfx++= '.';
}
static const char *pathbuf_sfx(Pathbuf *pb, const char *suffix) {
assert(strlen(suffix) <= MAX_SUFFIX);
/* Remove r where umask would remove w;
* eg umask intending 0664 here gives 0660 */
- *lockfd_r= open(pathbuf_sfx(pb,".lock"), O_RDONLY|O_CREAT, lockmode);
+ *lockfd_r= open(pathbuf_sfx(pb,".lock"), O_RDWR|O_CREAT, lockmode);
if (*lockfd_r < 0)
return cht_posixerr(ip, errno, "could not open/create lockfile");