From e64fd15e05981a2f0ea48c4dcfc324e04510e86a Mon Sep 17 00:00:00 2001 From: David Anderson Date: Wed, 20 Jul 2011 20:48:25 +0000 Subject: [PATCH] - server: debug the above svn path=/trunk/boinc/; revision=23864 --- checkin_notes | 6 ++++ sched/file_upload_handler.cpp | 65 ++++++++++++++++++++--------------- 2 files changed, 43 insertions(+), 28 deletions(-) diff --git a/checkin_notes b/checkin_notes index b0e841c695..1322d9b549 100644 --- a/checkin_notes +++ b/checkin_notes @@ -4258,3 +4258,9 @@ David 20 July 2011 client/ client_types.cpp,h file_xfer.cpp + +David 20 July 2011 + - server: debug the above + + sched/ + file_upload_handler.cpp diff --git a/sched/file_upload_handler.cpp b/sched/file_upload_handler.cpp index 9af7e610f2..9eee6d7686 100644 --- a/sched/file_upload_handler.cpp +++ b/sched/file_upload_handler.cpp @@ -242,25 +242,32 @@ void copy_socket_to_null(FILE* in) { // int handle_file_upload(FILE* in, R_RSA_PUBLIC_KEY& key) { char buf[256], path[512], signed_xml[1024]; - char name[256]; + char name[256], stemp[256]; double max_nbytes=-1; - char xml_signature[SIGNATURE_SIZE_TEXT]; + char xml_signature[1024]; int retval; double offset=0, nbytes = -1; - bool is_valid; + bool is_valid, btemp; strcpy(name, ""); strcpy(xml_signature, ""); bool found_data = false; while (fgets(buf, 256, in)) { -#if 0 +#if 1 log_messages.printf(MSG_NORMAL, "got:%s\n", buf); #endif if (match_tag(buf, "")) continue; if (match_tag(buf, "")) continue; if (match_tag(buf, "")) continue; if (match_tag(buf, "")) continue; - if (parse_str(buf, "", xml_signature, sizeof(xml_signature))) { + if (parse_bool(buf, "generated_locally", btemp)) continue; + if (parse_bool(buf, "upload_when_present", btemp)) continue; + if (parse_str(buf, "", stemp, sizeof(stemp))) continue; + if (parse_str(buf, "", stemp, sizeof(stemp))) continue; + if (match_tag(buf, "")) { + copy_element_contents( + in, "", xml_signature, sizeof(xml_signature) + ); continue; } if (parse_str(buf, "", name, sizeof(name))) { @@ -276,37 +283,39 @@ int handle_file_upload(FILE* in, R_RSA_PUBLIC_KEY& key) { } log_messages.printf(MSG_CRITICAL, "unrecognized: %s", buf); } + if (strlen(name) == 0) { + return return_error(ERR_PERMANENT, "Missing name"); + } if (!found_data) { return return_error(ERR_PERMANENT, "Missing tag"); } if (!config.ignore_upload_certificates) { if (strlen(xml_signature) == 0) { + return return_error(ERR_PERMANENT, "missing signature"); + } + if (max_nbytes < 0) { + return return_error(ERR_PERMANENT, "missing max_nbytes"); + } + sprintf(signed_xml, + "%s%.0f", + name, max_nbytes + ); + retval = verify_string( + signed_xml, xml_signature, key, is_valid + ); + if (retval || !is_valid) { log_messages.printf(MSG_CRITICAL, - "file info is missing signature\n" + "verify_string() [%s] [%s] retval %d, is_valid = %d\n", + signed_xml, xml_signature, + retval, is_valid + ); + log_messages.printf(MSG_NORMAL, + "signed xml: %s\n", signed_xml + ); + log_messages.printf(MSG_NORMAL, + "signature: %s\n", xml_signature ); return return_error(ERR_PERMANENT, "invalid signature"); - } else { - sprintf(signed_xml, - "%s%.0f", - name, max_nbytes - ); - retval = verify_string( - signed_xml, xml_signature, key, is_valid - ); - if (retval || !is_valid) { - log_messages.printf(MSG_CRITICAL, - "verify_string() [%s] [%s] retval %d, is_valid = %d\n", - signed_xml, xml_signature, - retval, is_valid - ); - log_messages.printf(MSG_NORMAL, - "signed xml: %s", signed_xml - ); - log_messages.printf(MSG_NORMAL, - "signature: %s", xml_signature - ); - return return_error(ERR_PERMANENT, "invalid signature"); - } } } if (nbytes < 0) {