Synchronet now requires the libarchive development package (e.g. libarchive-dev on Debian-based Linux distros, libarchive.org for more info) to build successfully.

Commits (10)
......@@ -1527,7 +1527,7 @@ js_revert_text(JSContext *cx, uintN argc, jsval *arglist)
}
i--;
if(i<0 || i>=TOTAL_TEXT) {
if(i>=TOTAL_TEXT) {
for(i=0;i<TOTAL_TEXT;i++) {
if(sbbs->text[i]!=sbbs->text_sav[i] && sbbs->text[i]!=nulstr)
free(sbbs->text[i]);
......
......@@ -1758,7 +1758,7 @@ js_write(JSContext *cx, uintN argc, jsval *arglist)
JS_SET_RVAL(cx, arglist, JSVAL_TRUE);
} else {
free(cp);
dbprintf(TRUE, p, "write of %u bytes failed",len);
dbprintf(TRUE, p, "write of %lu bytes failed", (ulong)len);
}
JS_RESUMEREQUEST(cx, rc);
......
......@@ -144,6 +144,7 @@ js_dump_file(JSContext *cx, uintN argc, jsval *arglist)
JSObject* array;
if((array = JS_NewArrayObject(cx, 0, NULL)) == NULL) {
free(filename);
strListFree(&list);
JS_ReportError(cx, "JS_NewArrayObject failure");
return JS_FALSE;
}
......@@ -275,6 +276,7 @@ parse_file_index_properties(JSContext *cx, JSObject* obj, fileidxrec_t* idx)
}
if(JS_GetProperty(cx, obj, prop_name = "size", &val) && !JSVAL_NULL_OR_VOID(val)) {
if(!JS_ValueToECMAUint32(cx, val, &idx->idx.size)) {
free(cp);
JS_ReportError(cx, "Error converting adding '%s' property to Uint32", prop_name);
return FALSE;
}
......@@ -285,6 +287,7 @@ parse_file_index_properties(JSContext *cx, JSObject* obj, fileidxrec_t* idx)
}
if(JS_GetProperty(cx, obj, prop_name = "crc32", &val) && !JSVAL_NULL_OR_VOID(val)) {
if(!JS_ValueToECMAUint32(cx, val, &idx->hash.data.crc32)) {
free(cp);
JS_ReportError(cx, "Error converting adding '%s' property to Uint32", prop_name);
return FALSE;
}
......@@ -380,6 +383,7 @@ parse_file_properties(JSContext *cx, JSObject* obj, file_t* file, char** extdesc
JSVALUE_TO_MSTRING(cx, val, *extdesc, NULL);
HANDLE_PENDING(cx, *extdesc);
if(*extdesc == NULL) {
free(cp);
JS_ReportError(cx, "Invalid '%s' string in file object", prop_name);
return SMB_ERR_MEM;
}
......@@ -403,6 +407,7 @@ parse_file_properties(JSContext *cx, JSObject* obj, file_t* file, char** extdesc
if(JS_GetProperty(cx, obj, prop_name, &val) && !JSVAL_NULL_OR_VOID(val)) {
uint32_t cost = 0;
if(!JS_ValueToECMAUint32(cx, val, &cost)) {
free(cp);
JS_ReportError(cx, "Error converting adding '%s' property to Uint32", prop_name);
return SMB_FAILURE;
}
......@@ -529,9 +534,9 @@ js_get_file(JSContext *cx, uintN argc, jsval *arglist)
argn++;
}
if(argn < argc && JSVAL_IS_OBJECT(argv[argn])) {
free(filename);
if(!parse_file_index_properties(cx, JSVAL_TO_OBJECT(argv[argn]), &file.file_idx))
return JS_TRUE;
free(filename);
filename = strdup(file.file_idx.name);
argn++;
}
......
......@@ -279,8 +279,7 @@ static JSBool js_sub_get(JSContext *cx, JSObject *obj, jsid id, jsval *vp)
*vp = BOOLEAN_TO_JSVAL(p->user == NULL || is_user_subop(p->cfg, p->subnum, p->user, p->client));
break;
case SUB_PROP_IS_MODERATED:
if(p->cfg->sub[p->subnum]->mod_ar != NULL
&& p->cfg->sub[p->subnum]->mod_ar[0] != 0
if(p->cfg->sub[p->subnum]->mod_ar[0] != 0
&& p->user != NULL
&& chk_ar(p->cfg,p->cfg->sub[p->subnum]->mod_ar, p->user, p->client))
*vp = JSVAL_TRUE;
......
......@@ -915,6 +915,7 @@ js_connect_event_thread(void *args)
done:
closesocket(a->sv[1]);
freeaddrinfo(res);
free(a);
}
......@@ -3332,8 +3333,8 @@ js_listening_socket_constructor(JSContext *cx, uintN argc, jsval *arglist)
}
else {
if (!JS_GetArrayLength(cx, obj, &count)) {
free(protocol);
return JS_FALSE;
JS_ReportError(cx, "zero-length array");
goto fail;
}
for (i = 0; (jsuint)i < count; i++) {
if (!JS_GetElement(cx, obj, i, &v)) {
......@@ -3407,8 +3408,7 @@ js_listening_socket_constructor(JSContext *cx, uintN argc, jsval *arglist)
return(JS_TRUE);
fail:
if (protocol)
free(protocol);
free(protocol);
free(set);
return JS_FALSE;
}
......
......@@ -1227,66 +1227,44 @@ js_spamlog(JSContext *cx, uintN argc, jsval *arglist)
if((sys = (js_system_private_t*)js_GetClassPrivate(cx,obj,&js_system_class))==NULL)
return JS_FALSE;
for(i=0;i<argc;i++) {
for(i=0;i<argc && from == NULL;i++) {
if(!JSVAL_IS_STRING(argv[i]))
continue;
if(from==NULL) {
JSVALUE_TO_MSTRING(cx, argv[i], p, NULL);
if(JS_IsExceptionPending(cx)) {
if(prot)
free(prot);
if(action)
free(action);
if(reason)
free(reason);
if(host)
free(host);
if(ip_addr)
free(ip_addr);
if(to)
free(to);
if(from)
free(from);
if(p)
free(p);
return JS_FALSE;
}
if(p==NULL)
continue;
if(prot==NULL)
prot=p;
else if(action==NULL)
action=p;
else if(reason==NULL)
reason=p;
else if(host==NULL)
host=p;
else if(ip_addr==NULL)
ip_addr=p;
else if(to==NULL)
to=p;
else if(from==NULL)
from=p;
else
free(p);
JSVALUE_TO_MSTRING(cx, argv[i], p, NULL);
if(p == NULL || JS_IsExceptionPending(cx)) {
free(prot);
free(action);
free(reason);
free(host);
free(ip_addr);
free(to);
free(p);
return JS_FALSE;
}
if(prot==NULL)
prot=p;
else if(action==NULL)
action=p;
else if(reason==NULL)
reason=p;
else if(host==NULL)
host=p;
else if(ip_addr==NULL)
ip_addr=p;
else if(to==NULL)
to=p;
else
from=p;
}
rc=JS_SUSPENDREQUEST(cx);
ret=spamlog(sys->cfg,prot,action,reason,host,ip_addr,to,from);
if(prot)
free(prot);
if(action)
free(action);
if(reason)
free(reason);
if(host)
free(host);
if(ip_addr)
free(ip_addr);
if(to)
free(to);
if(from)
free(from);
free(prot);
free(action);
free(reason);
free(host);
free(ip_addr);
free(to);
free(from);
JS_RESUMEREQUEST(cx, rc);
JS_SET_RVAL(cx, arglist, BOOLEAN_TO_JSVAL(ret));
return(JS_TRUE);
......@@ -1328,41 +1306,29 @@ js_hacklog(JSContext *cx, uintN argc, jsval *arglist)
continue;
if(host==NULL) {
JSVALUE_TO_MSTRING(cx, argv[i], p, NULL);
if(JS_IsExceptionPending(cx)) {
if(prot)
free(prot);
if(user)
free(user);
if(text)
free(text);
if(host)
free(host);
if(p)
free(p);
if(JS_IsExceptionPending(cx) || p == NULL) {
free(prot);
free(user);
free(text);
free(p);
return JS_FALSE;
}
if(prot==NULL)
prot=p;
else if(user==NULL)
user=p;
else if(text==NULL)
text=p;
else
host=p;
}
if(p==NULL)
continue;
if(prot==NULL)
prot=p;
else if(user==NULL)
user=p;
else if(text==NULL)
text=p;
else if(host==NULL)
host=p;
}
rc=JS_SUSPENDREQUEST(cx);
ret=hacklog(sys->cfg,prot,user,text,host,&addr);
if(prot)
free(prot);
if(user)
free(user);
if(text)
free(text);
if(host)
free(host);
free(prot);
free(user);
free(text);
free(host);
JS_RESUMEREQUEST(cx, rc);
JS_SET_RVAL(cx, arglist, BOOLEAN_TO_JSVAL(ret));
return(JS_TRUE);
......@@ -1390,31 +1356,19 @@ js_filter_ip(JSContext *cx, uintN argc, jsval *arglist)
if((sys = (js_system_private_t*)js_GetClassPrivate(cx,obj,&js_system_class))==NULL)
return JS_FALSE;
for(i=0;i<argc;i++) {
for(i=0; i<argc && fname == NULL; i++) {
if(!JSVAL_IS_STRING(argv[i]))
continue;
if(fname==NULL) {
JSVALUE_TO_MSTRING(cx, argv[i], p, NULL);
if(JS_IsExceptionPending(cx)) {
if(prot)
free(prot);
if(reason)
free(reason);
if(host)
free(host);
if(ip_addr)
free(ip_addr);
if(from)
free(from);
if(fname)
free(fname);
if(p)
free(p);
return JS_FALSE;
}
JSVALUE_TO_MSTRING(cx, argv[i], p, NULL);
if(JS_IsExceptionPending(cx) || p == NULL) {
free(prot);
free(reason);
free(host);
free(ip_addr);
free(from);
free(p);
return JS_FALSE;
}
if(p==NULL)
continue;
if(prot==NULL)
prot=p;
else if(reason==NULL)
......@@ -1425,23 +1379,17 @@ js_filter_ip(JSContext *cx, uintN argc, jsval *arglist)
ip_addr=p;
else if(from==NULL)
from=p;
else if(fname==NULL)
else
fname=p;
}
rc=JS_SUSPENDREQUEST(cx);
ret=filter_ip(sys->cfg,prot,reason,host,ip_addr,from,fname);
if(prot)
free(prot);
if(reason)
free(reason);
if(host)
free(host);
if(ip_addr)
free(ip_addr);
if(from)
free(from);
if(fname)
free(fname);
free(prot);
free(reason);
free(host);
free(ip_addr);
free(from);
free(fname);
JS_RESUMEREQUEST(cx, rc);
JS_SET_RVAL(cx, arglist, BOOLEAN_TO_JSVAL(ret));
return(JS_TRUE);
......
......@@ -585,7 +585,7 @@ void sbbs_t::qwk_sec()
off_t l=flength(str);
bprintf(text[FiFilename], getfname(str));
bprintf(text[FiFileSize], ultoac((ulong)l,tmp)
, byte_estimate_to_str(l, tmp2, sizeof(tmp), /* units: */1024, /* precision: */1));
, byte_estimate_to_str(l, tmp2, sizeof(tmp2), /* units: */1024, /* precision: */1));
if(l>0L && cur_cps)
i=(uint)(l/(ulong)cur_cps);
......
......@@ -2292,7 +2292,7 @@ int unpack(const char *infile, const char* outdir)
break;
}
sprintf(tmp,"%02X",ch);
strcat(str,tmp);
SAFECAT(str,tmp);
}
if(!stricmp(str,cfg.arcdef[u].hexid))
break;
......
......@@ -2247,6 +2247,7 @@ void DLLCALL services_thread(void* arg)
,service[i].protocol, host_ip, inet_addrport(&client_addr));
if(service[i].max_clients && protected_uint32_value(service[i].clients) + 1 > service[i].max_clients) {
FREE_AND_NULL(udp_buf);
lprintf(LOG_WARNING,"%04d %s !MAXIMUM CLIENTS (%u) reached, access denied"
,client_socket, service[i].protocol, service[i].max_clients);
close_socket(client_socket);
......
......@@ -549,7 +549,7 @@ bool upgrade_file_bases(bool hash)
for(int i = 0; i < scfg.total_dirs; i++) {
smb_t smb;
SAFEPRINTF2(smb.file, "%s%s", scfg.dir[i]->data_dir, scfg.dir[i]->code);
(void)smb_init_dir(&scfg, &smb, i);
if((result = smb_open(&smb)) != SMB_SUCCESS) {
fprintf(stderr, "Error %d (%s) opening %s\n", result, smb.last_error, smb.file);
return false;
......@@ -571,12 +571,14 @@ bool upgrade_file_bases(bool hash)
sprintf(str,"%s%s.ixb",scfg.dir[i]->data_dir,scfg.dir[i]->code);
if((file=open(str,O_RDONLY|O_BINARY))==-1) {
smb_close(&smb);
closeextdesc(extfile);
continue;
}
long l=(long)filelength(file);
if(!l) {
close(file);
smb_close(&smb);
closeextdesc(extfile);
continue;
}
uchar* ixbbuf;
......@@ -584,6 +586,7 @@ bool upgrade_file_bases(bool hash)
close(file);
printf("\7ERR_ALLOC %s %lu\n",str,l);
smb_close(&smb);
closeextdesc(extfile);
continue;
}
if(read(file,ixbbuf,l)!=(int)l) {
......@@ -591,6 +594,7 @@ bool upgrade_file_bases(bool hash)
printf("\7ERR_READ %s %lu\n",str,l);
free(ixbbuf);
smb_close(&smb);
closeextdesc(extfile);
continue;
}
close(file);
......@@ -598,6 +602,9 @@ bool upgrade_file_bases(bool hash)
oldfile_t* filelist = malloc(sizeof(*filelist) * file_count);
if(filelist == NULL) {
printf("malloc failure");
free(ixbbuf);
smb_close(&smb);
closeextdesc(extfile);
return false;
}
memset(filelist, 0, sizeof(*filelist) * file_count);
......