mirror of
https://gitlab.xiph.org/xiph/icecast-server.git
synced 2024-12-04 14:46:30 -05:00
using .filename causes problems with absolute paths for the temp file, also
test to see if file exists already svn path=/icecast/trunk/icecast/; revision=9407
This commit is contained in:
parent
ad1e6c41b0
commit
fd19feb3c5
15
src/auth.c
15
src/auth.c
@ -22,6 +22,8 @@
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include "auth.h"
|
||||
#include "source.h"
|
||||
@ -354,6 +356,7 @@ int auth_htpasswd_deleteuser(auth_t *auth, char *username)
|
||||
char *sep;
|
||||
char *tmpfile = NULL;
|
||||
int tmpfile_len = 0;
|
||||
struct stat file_info;
|
||||
|
||||
state = auth->state;
|
||||
passwdfile = fopen(state->filename, "rb");
|
||||
@ -363,10 +366,16 @@ int auth_htpasswd_deleteuser(auth_t *auth, char *username)
|
||||
state->filename, strerror(errno));
|
||||
return AUTH_FAILED;
|
||||
}
|
||||
tmpfile_len = strlen(state->filename) + 6;
|
||||
tmpfile_len = strlen(state->filename) + 5;
|
||||
tmpfile = calloc(1, tmpfile_len);
|
||||
sprintf(tmpfile, ".%s.tmp", state->filename);
|
||||
|
||||
snprintf (tmpfile, tmpfile_len, "%s.tmp", state->filename);
|
||||
if (stat (tmpfile, &file_info) == 0)
|
||||
{
|
||||
WARN1 ("temp file \"%s\" exists, rejecting operation", tmpfile);
|
||||
free (tmpfile);
|
||||
fclose (passwdfile);
|
||||
return AUTH_FAILED;
|
||||
}
|
||||
tmp_passwdfile = fopen(tmpfile, "wb");
|
||||
|
||||
if(tmp_passwdfile == NULL) {
|
||||
|
Loading…
Reference in New Issue
Block a user