if (ptr == NULL) break;
strcpy(ptr, "");
for (i = 0; i < num_tokens(nttlist, '|'); ++i) {
- extract(buf, nttlist, i);
+ extract_token(buf, nttlist, i, '|', sizeof buf);
if ( (strlen(buf) > 0)
&& (strcasecmp(buf, nodename)) ) {
strcat(ptr, buf);
if (nttlist == NULL) break;
if (strlen(nttlist) == 0) break;
for (i = 0; i < num_tokens(nttlist, '|'); ++i) {
- extract(buf, nttlist, i);
+ extract_token(buf, nttlist, i, '|', sizeof buf);
if (!strcasecmp(buf, nodename)) ++retval;
}
break;
*/
void cmd_movf(char *cmdbuf)
{
- char filename[SIZ];
- char pathname[SIZ];
- char newpath[SIZ];
- char newroom[SIZ];
- char buf[SIZ];
+ char filename[PATH_MAX];
+ char pathname[PATH_MAX];
+ char newpath[PATH_MAX];
+ char newroom[ROOMNAMELEN];
+ char buf[PATH_MAX];
int a;
struct ctdlroom qrbuf;
- extract(filename, cmdbuf, 0);
- extract(newroom, cmdbuf, 1);
+ extract_token(filename, cmdbuf, 0, '|', sizeof filename);
+ extract_token(newroom, cmdbuf, 1, '|', sizeof newroom);
if (CtdlAccessCheck(ac_room_aide)) return;
*/
void cmd_netf(char *cmdbuf)
{
- char pathname[SIZ], filename[SIZ], destsys[SIZ], buf[SIZ];
- char outfile[SIZ];
+ char pathname[256], filename[256], destsys[256], buf[256];
+ char outfile[256];
int a, e;
time_t now;
FILE *ofp;
static int seq = 1;
- extract(filename, cmdbuf, 0);
- extract(destsys, cmdbuf, 1);
+ extract_token(filename, cmdbuf, 0, '|', sizeof filename);
+ extract_token(destsys, cmdbuf, 1, '|', sizeof destsys);
if (CtdlAccessCheck(ac_room_aide)) return;
*/
void cmd_open(char *cmdbuf)
{
- char filename[SIZ];
- char pathname[SIZ];
+ char filename[256];
+ char pathname[PATH_MAX];
int a;
- extract(filename, cmdbuf, 0);
+ extract_token(filename, cmdbuf, 0, '|', sizeof filename);
if (CtdlAccessCheck(ac_logged_in)) return;
*/
void cmd_oimg(char *cmdbuf)
{
- char filename[SIZ];
- char pathname[SIZ];
+ char filename[256];
+ char pathname[PATH_MAX];
struct ctdluser usbuf;
char which_user[USERNAME_SIZE];
int which_floor;
int a;
- extract(filename, cmdbuf, 0);
+ extract_token(filename, cmdbuf, 0, '|', sizeof filename);
if (strlen(filename) == 0) {
cprintf("%d You must specify a file name.\n",
}
if (!strcasecmp(filename, "_userpic_")) {
- extract(which_user, cmdbuf, 1);
+ extract_token(which_user, cmdbuf, 1, '|', sizeof which_user);
if (getuser(&usbuf, which_user) != 0) {
cprintf("%d No such user.\n",
ERROR + NO_SUCH_USER);
{
int a;
- extract(CC->upl_file, cmdbuf, 0);
- extract(CC->upl_comment, cmdbuf, 1);
+ extract_token(CC->upl_file, cmdbuf, 0, '|', sizeof CC->upl_file);
+ extract_token(CC->upl_comment, cmdbuf, 1, '|', sizeof CC->upl_comment);
if (CtdlAccessCheck(ac_logged_in)) return;
void cmd_uimg(char *cmdbuf)
{
int is_this_for_real;
- char basenm[SIZ];
+ char basenm[256];
int which_floor;
int a;
}
is_this_for_real = extract_int(cmdbuf, 0);
- extract(basenm, cmdbuf, 1);
+ extract_token(basenm, cmdbuf, 1, '|', sizeof basenm);
if (CC->upload_fp != NULL) {
cprintf("%d You already have an upload file open.\n",
ERROR + RESOURCE_BUSY);
*/
void cmd_clos(void)
{
- char buf[SIZ];
+ char buf[256];
if (CC->download_fp == NULL) {
cprintf("%d You don't have a download file open.\n",
long start_pos;
size_t bytes;
size_t actual_bytes;
- char buf[4096];
+ char *buf = NULL;
start_pos = extract_long(cmdbuf, 0);
bytes = extract_int(cmdbuf, 1);
return;
}
- if (bytes > 4096) bytes = 4096;
+ if (bytes > 100000) bytes = 100000;
+ buf = malloc(bytes + 1);
fseek(CC->download_fp, start_pos, 0);
actual_bytes = fread(buf, 1, bytes, CC->download_fp);
cprintf("%d %d\n", BINARY_FOLLOWS, (int)actual_bytes);
client_write(buf, actual_bytes);
+ free(buf);
}
void cmd_writ(char *cmdbuf)
{
int bytes;
- char buf[4096];
+ char *buf;
unbuffer_output();
return;
}
- if (bytes > 4096) {
- cprintf("%d You may not write more than 4096 bytes.\n",
+ if (bytes > 100000) {
+ cprintf("%d You may not write more than 100000 bytes.\n",
ERROR + TOO_BIG);
return;
}
cprintf("%d %d\n", SEND_BINARY, bytes);
+ buf = malloc(bytes + 1);
client_read(buf, bytes);
fwrite(buf, bytes, 1, CC->upload_fp);
+ free(buf);
}
*/
void cmd_ndop(char *cmdbuf)
{
- char pathname[SIZ];
+ char pathname[256];
struct stat statbuf;
if (strlen(CC->net_node) == 0) {