diff options
author | Matthias Andree <matthias.andree@gmx.de> | 2004-11-10 20:38:06 +0000 |
---|---|---|
committer | Matthias Andree <matthias.andree@gmx.de> | 2004-11-10 20:38:06 +0000 |
commit | cfde1cceb2c9c460036fd512e3bac1d579c74af6 (patch) | |
tree | c396c99a28efbdab430ce8eb6fbcb8c25367ebf5 /lock.c | |
parent | 4f3f4551ff4f97d6278956fc525a78c1fe0866fa (diff) | |
download | fetchmail-cfde1cceb2c9c460036fd512e3bac1d579c74af6.tar.gz fetchmail-cfde1cceb2c9c460036fd512e3bac1d579c74af6.tar.bz2 fetchmail-cfde1cceb2c9c460036fd512e3bac1d579c74af6.zip |
Misc. sprintf and pid_t fixes.
svn path=/trunk/; revision=4000
Diffstat (limited to 'lock.c')
-rw-r--r-- | lock.c | 10 |
1 files changed, 6 insertions, 4 deletions
@@ -32,7 +32,9 @@ void lock_setup(void) if (getuid() == ROOT_UID) { lockfile = (char *)xmalloc( sizeof(PID_DIR) + sizeof(FETCHMAIL_PIDFILE) + 1); - sprintf(lockfile, "%s/%s", PID_DIR, FETCHMAIL_PIDFILE); + strcpy(lockfile, PID_DIR); + strcat(lockfile, "/"); + strcat(lockfile, FETCHMAIL_PIDFILE); } else { lockfile = (char *)xmalloc(strlen(fmhome)+sizeof(FETCHMAIL_PIDFILE)+2); strcpy(lockfile, fmhome); @@ -98,7 +100,7 @@ void lock_or_die(void) /* get a lock on a given host or exit */ { int fd; - char tmpbuf[20]; + char tmpbuf[50]; #ifndef O_SYNC #define O_SYNC 0 /* use it if we have it */ @@ -107,11 +109,11 @@ void lock_or_die(void) { if ((fd = open(lockfile, O_WRONLY|O_CREAT|O_EXCL|O_SYNC, 0666)) != -1) { - sprintf(tmpbuf,"%d", getpid()); + snprintf(tmpbuf, sizeof(tmpbuf), "%ld", (long)getpid()); write(fd, tmpbuf, strlen(tmpbuf)); if (run.poll_interval) { - sprintf(tmpbuf," %d", run.poll_interval); + snprintf(tmpbuf, sizeof(tmpbuf), " %d", run.poll_interval); write(fd, tmpbuf, strlen(tmpbuf)); } close(fd); /* should be safe, fd was opened with O_SYNC */ |