Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion zipscript/src/audiosort-bin.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ int main(int argc, char *argv[])
printf("Something bad happened when trying to decide what dir to resort.\n");
return 1;
}
snprintf(targetDir, PATH_MAX, "%s/%s", cwdDir, argv[1]);
safe_snprintf(targetDir, PATH_MAX, "%s/%s", cwdDir, argv[1]);
}
}
}
Expand Down
3 changes: 1 addition & 2 deletions zipscript/src/audiosort.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@

void audioSortDir(char *targetDir)
{
int cnt = 0;
char link_source[PATH_MAX], link_target[PATH_MAX], *file_target = NULL;
struct audio info;
DIR *ourDir;
Expand All @@ -41,7 +40,7 @@ void audioSortDir(char *targetDir)
* readsfv(sfv_data, &g.v, 0);
*/

cnt = extractDirname(link_target, targetDir);
extractDirname(link_target, targetDir);
strlcpy(link_source, targetDir, PATH_MAX);

if (chdir(targetDir) == -1) {
Expand Down
13 changes: 4 additions & 9 deletions zipscript/src/convert.c
Original file line number Diff line number Diff line change
Expand Up @@ -403,10 +403,10 @@ convert_audio(struct VARS *raceI, char *instr)
char *
convert_sitename(char *instr)
{
int val1, val2;
char *out_p;
char *m;
char ctrl[15];
int val1;
char *out_p;
char *m;
char ctrl[15];

out_p = output2;

Expand Down Expand Up @@ -436,12 +436,7 @@ convert_sitename(char *instr)
instr++;
if (m != instr && instr-m < (int)sizeof(ctrl)) {
sprintf(ctrl, "%.*s", (int)(instr - m), m);
val2 = strtol(ctrl, NULL, 10);
} else {
val2 = 0;
}
} else {
val2 = -1;
}

switch (*instr) {
Expand Down
2 changes: 1 addition & 1 deletion zipscript/src/mp3info.c
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ get_id3(mp3info * mp3, struct audio *audio)
{
int retcode = 1;
char fbuf [4];
int ignore = 0;
int ignore;

if (mp3->datasize > 128) {
if (fseek(mp3->file, -128, SEEK_END)) {
Expand Down
2 changes: 1 addition & 1 deletion zipscript/src/postdel.c
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ main(int argc, char **argv)
if (temp_p) {
while ((signed)strlen(temp_p) - 4 > 0)
temp_p++;
snprintf(fileext, 4, "%s", temp_p);
safe_snprintf(fileext, 4, "%s", temp_p);
} else
*fileext = '\0';

Expand Down
23 changes: 13 additions & 10 deletions zipscript/src/postunnuke.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
int
main(int argc, char *argv[])
{
int k, n, m, l, complete_type = 0;
int k, n, l, complete_type = 0;

#ifdef USING_GLFTPD
int gnum = 0, unum = 0;
Expand All @@ -47,8 +47,11 @@ main(int argc, char *argv[])
unsigned int crc;
struct stat fileinfo;

#ifdef USING_GLFTPD
uid_t f_uid;
gid_t f_gid;
#endif

double temp_time = 0;

DIR *dir, *parent;
Expand Down Expand Up @@ -247,23 +250,23 @@ main(int argc, char *argv[])
rewinddir(dir);
timenow = time(NULL);
while ((dp = readdir(dir))) {
m = l = (int)strlen(dp->d_name);
l = (int)strlen(dp->d_name);

ext = find_last_of(dp->d_name, ".");
if (*ext == '.')
ext++;

if (!strcasecmp(ext, "zip")) {
stat(dp->d_name, &fileinfo);
f_uid = fileinfo.st_uid;
f_gid = fileinfo.st_gid;

if ((timenow == fileinfo.st_ctime) && (fileinfo.st_mode & 0111)) {
d_log("ng-post_unnuke: Seems this file (%s) is in the process of being uploaded. Ignoring for now.\n", dp->d_name);
continue;
}

#ifdef USING_GLFTPD
f_uid = fileinfo.st_uid;
f_gid = fileinfo.st_gid;
strcpy(g.v.user.name, get_u_name(f_uid));
strcpy(g.v.user.group, get_g_name(f_gid));
#else
Expand Down Expand Up @@ -296,7 +299,7 @@ main(int argc, char *argv[])
writerace(g.l.race, &g.v, crc, F_CHECKED);
} else {
writerace(g.l.race, &g.v, crc, F_BAD);
if (g.v.file.name)
if (strlen(g.v.file.name) > 0)
unlink(g.v.file.name);
}
}
Expand Down Expand Up @@ -390,7 +393,7 @@ main(int argc, char *argv[])

if (copysfv(g.v.file.name, g.l.sfv, &g.v)) {
while ((dp = readdir(dir))) {
m = l = (int)strlen(dp->d_name);
l = (int)strlen(dp->d_name);
ext = find_last_of(dp->d_name, "-");
if (!strncmp(ext, "-missing", 8))
unlink(dp->d_name);
Expand All @@ -415,7 +418,7 @@ main(int argc, char *argv[])
g.v.total.start_time = 0;
rewinddir(dir);
while ((dp = readdir(dir))) {
m = l = (int)strlen(dp->d_name);
l = (int)strlen(dp->d_name);

ext = find_last_of(dp->d_name, ".");
if (*ext == '.')
Expand Down Expand Up @@ -444,10 +447,10 @@ main(int argc, char *argv[])
if (ignore_zero_sized_on_rescan && !fileinfo.st_size)
continue;

f_uid = fileinfo.st_uid;
f_gid = fileinfo.st_gid;

#ifdef USING_GLFTPD
f_uid = fileinfo.st_uid;
f_gid = fileinfo.st_gid;
strcpy(g.v.user.name, get_u_name(f_uid));
strcpy(g.v.user.group, get_g_name(f_gid));
#else
Expand Down Expand Up @@ -493,7 +496,7 @@ main(int argc, char *argv[])
crc = 1;

if (!S_ISDIR(fileinfo.st_mode)) {
if (g.v.file.name)
if (strlen(g.v.file.name) > 0)
unlink_missing(g.v.file.name);
}
if ((g.l.race && !match_file(g.l.race, dp->d_name)) || !fileexists(dp->d_name))
Expand Down
1 change: 0 additions & 1 deletion zipscript/src/race-file.c
Original file line number Diff line number Diff line change
Expand Up @@ -1196,7 +1196,6 @@ remove_lock(struct VARS *raceI)
{
int fd;
HEADDATA hd;
char lockfile[PATH_MAX + 1];

if ((fd = open(raceI->headpath, O_RDWR, 0666)) == -1) {
d_log_ext("remove_lock", "open(%s): %s\n", raceI->headpath, strerror(errno));
Expand Down
15 changes: 8 additions & 7 deletions zipscript/src/rescan.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,10 @@ main(int argc, char *argv[])
unsigned int crc;
struct stat fileinfo;

#ifdef USING_GLFTPD
uid_t f_uid;
gid_t f_gid;
#endif
double temp_time = 0;

DIR *dir, *parent;
Expand Down Expand Up @@ -376,13 +378,13 @@ main(int argc, char *argv[])
ext++;
if (!strcasecmp(ext, "zip")) {
stat(dp->d_name, &fileinfo);
f_uid = fileinfo.st_uid;
f_gid = fileinfo.st_gid;
if ((timenow == fileinfo.st_ctime) && (fileinfo.st_mode & 0111)) {
d_log("rescan.c: Seems this file (%s) is in the process of being uploaded. Ignoring for now.\n", dp->d_name);
continue;
}
#ifdef USING_GLFTPD
f_uid = fileinfo.st_uid;
f_gid = fileinfo.st_gid;
strlcpy(g.v.user.name, get_u_name(f_uid), sizeof(g.v.user.name));
strlcpy(g.v.user.group, get_g_name(f_gid), sizeof(g.v.user.group));
#else
Expand All @@ -408,7 +410,7 @@ main(int argc, char *argv[])
writerace(g.l.race, &g.v, crc, F_CHECKED);
} else {
writerace(g.l.race, &g.v, crc, F_BAD);
if (g.v.file.name)
if (strlen(g.v.file.name) > 0)
unlink(g.v.file.name);
removedir(".unzipped");
continue;
Expand All @@ -418,7 +420,7 @@ main(int argc, char *argv[])
if ((!findfileextcount(dir, ".nfo") || findfileextcount(dir, ".zip")) && check_zipfile(".unzipped", g.v.file.name, findfileextcount(dir, ".nfo"))) {
d_log("rescan: File %s is password protected.\n", g.v.file.name);
writerace(g.l.race, &g.v, crc, F_BAD);
if (g.v.file.name)
if (strlen(g.v.file.name) > 0)
unlink(g.v.file.name);
seekdir(dir, tempstream);
continue;
Expand Down Expand Up @@ -615,10 +617,9 @@ main(int argc, char *argv[])
if (ignore_zero_sized_on_rescan && !fileinfo.st_size)
continue;

#ifdef USING_GLFTPD
f_uid = fileinfo.st_uid;
f_gid = fileinfo.st_gid;

#ifdef USING_GLFTPD
strlcpy(g.v.user.name, get_u_name(f_uid), sizeof(g.v.user.name));
strlcpy(g.v.user.group, get_g_name(f_gid), sizeof(g.v.user.group));
#else
Expand Down Expand Up @@ -664,7 +665,7 @@ main(int argc, char *argv[])
crc = 1;

if (!S_ISDIR(fileinfo.st_mode)) {
if (g.v.file.name)
if (strlen(g.v.file.name) > 0)
unlink_missing(g.v.file.name);
if (l > 44) {
if (crc == 1)
Expand Down
13 changes: 12 additions & 1 deletion zipscript/src/zipscript-c.c
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ main(int argc, char **argv)
char *norace_halfway_type = 0;
char *inc_point[2];
char *affillist = 0;
unsigned char affil_upload = FALSE;

#ifdef _WITH_SS5
unsigned char complete_type = 1;
#else
Expand Down Expand Up @@ -529,9 +529,14 @@ main(int argc, char **argv)
break;
}


if (strlen(zipscript_header))
printf(zipscript_header);


#if (enable_affil_script == TRUE )
unsigned char affil_upload = FALSE;
#endif
/* Hide users in group_dirs */
if (hide_group_uploaders && matchpath(group_dirs, g.l.path)) {
d_log("zipscript-c: Hiding user in group-dir:\n");
Expand All @@ -554,7 +559,9 @@ main(int argc, char **argv)
affillist = ng_realloc2(affillist, 5000, 1, 1, 1);
create_dirlist(group_dirs, affillist, 5000);
if (strlen(affillist) && strcomp(affillist, g.v.user.group)) {
#if (enable_affil_script == TRUE )
affil_upload = TRUE;
#endif
d_log("zipscript-c: Hiding affil group based on group_dirs:\n");
if ((int)strlen(hide_affil_gname)) {
d_log("zipscript-c: Changing groupname.\n");
Expand All @@ -576,7 +583,9 @@ main(int argc, char **argv)
ng_free(affillist);
}
if (strlen(hide_affil_groups) && strcomp(hide_affil_groups, g.v.user.group)) {
#if (enable_affil_script == TRUE )
affil_upload = TRUE;
#endif
d_log("zipscript-c: Hiding affil group:\n");
if ((int)strlen(hide_affil_gname)) {
d_log("zipscript-c: Changing groupname.\n");
Expand All @@ -596,7 +605,9 @@ main(int argc, char **argv)
d_log("zipscript-c: No hidename given.\n");
}
if (strlen(hide_affil_users) && strcomp(hide_affil_users, g.v.user.name)) {
#if (enable_affil_script == TRUE )
affil_upload = TRUE;
#endif
d_log("zipscript-c: Hiding affil user:\n");
if ((int)strlen(hide_affil_uname)) {
d_log("zipscript-c: Changing username.\n");
Expand Down
2 changes: 1 addition & 1 deletion zipscript/src/zsfunctions.c
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ vd_log(const char *fmt, va_list ap)

#if ( debug_altlog == TRUE )
getcwd(debugpath, PATH_MAX);
snprintf(debugname, PATH_MAX, "%s/%s/debug",
safe_snprintf(debugname, PATH_MAX, "%s/%s/debug",
storage, debugpath);
#endif

Expand Down