AmendHub

Download:

jcs

/

subtext

/

amendments

/

200

folder: Fix notes field entry size, use shorter, random upload filename


jcs made amendment 200 about 1 year ago
--- folder.c Tue Jul 12 22:49:24 2022 +++ folder.c Tue Jul 12 23:32:16 2022 @@ -345,16 +345,14 @@ folder_upload(struct session *s, struct folder *folder char *initial_filename, char *initial_description) { char upload_path[256] = { 0 }; - char time[32]; struct folder_file file = { 0 }; FILE *fp; SHA1_CTX sha1; struct stat sb; - unsigned long now; struct zmodem_session *zs; char *data = NULL, *tmp = NULL, *errorstr = NULL; size_t size; - short c, ret, error; + short c, n, ret, error; if (!s->user) { session_printf(s, "Uploading is not available to guests.\r\n" @@ -382,10 +380,8 @@ folder_upload(struct session *s, struct folder *folder session_flush(s); session_pause_return(s, 0, "when you are ready..."); - now = Time; - strftime(time, sizeof(time), "%Y%m%d%H%M%S", localtime(&now)); - snprintf(upload_path, sizeof(upload_path), - "%s:upload-%s-%ld", folder->path, time, s->log.id); + snprintf(upload_path, sizeof(upload_path), "%s:upload-%08lx%08lx", + folder->path, xorshift32(), xorshift32()); zs = ZCreateReceiver(s, upload_path); zs->DoIACEscape = s->is_telnet; @@ -541,11 +537,12 @@ file_upload_annotate: } for (;;) { - session_printf(s, "{{B}}Notes:{{/B}} (Optional, ^D when finished.)\r\n"); + session_printf(s, + "{{B}}Notes (Optional, ^D when finished):{{/B}}\r\n"); session_flush(s); - - tmp = session_field_input(s, FOLDER_FILE_DESCR_LENGTH, - FOLDER_FILE_DESCR_LENGTH - 1, file.notes, true, 0); + + tmp = session_field_input(s, 2048, s->terminal_columns - 1, + file.notes, true, 0); if (file.notes != NULL) free(file.notes); file.notes = tmp;