/* * This could be further simplified by constructing an expected * HANDSHAKE_RESULT, and implementing comparison methods for * its fields. */ static int check_test(HANDSHAKE_RESULT result, SSL_TEST_CTX *test_ctx) { int ret = 1; ret &= check_result(result, test_ctx); ret &= check_alerts(result, test_ctx); if (result.result == SSL_TEST_SUCCESS) { ret &= check_protocol(result, test_ctx); ret &= check_servername(result, test_ctx); ret &= check_session_ticket(result, test_ctx); ret &= (result.session_ticket_do_not_call == 0); } return ret; }
/* * This could be further simplified by constructing an expected * HANDSHAKE_RESULT, and implementing comparison methods for * its fields. */ static int check_test(HANDSHAKE_RESULT *result, SSL_TEST_CTX *test_ctx) { int ret = 1; ret &= check_result(result, test_ctx); ret &= check_alerts(result, test_ctx); if (result->result == SSL_TEST_SUCCESS) { ret &= check_protocol(result, test_ctx); ret &= check_servername(result, test_ctx); ret &= check_session_ticket(result, test_ctx); ret &= (result->session_ticket_do_not_call == 0); #ifndef OPENSSL_NO_NEXTPROTONEG ret &= check_npn(result, test_ctx); #endif ret &= check_alpn(result, test_ctx); ret &= check_resumption(result, test_ctx); ret &= check_tmp_key(result, test_ctx); } return ret; }
int afp_parse_url(struct afp_url * url, const char * toparse, int verbose) { char firstpart[255],secondpart[2048]; char *p, *q; int firstpartlen; int skip_earliestpart=0; int skip_secondpart=0; char * lastchar; int foundv6literal=0; if (verbose) printf("Parsing %s\n",toparse); url->username[0]='\0'; url->servername[0]='\0'; url->uamname[0]='\0'; url->password[0]='\0'; url->volumename[0]='\0'; url->path[0]='\0'; /* The most complex URL is: afp://user;AUTH=authType:password@server-name:port/volume-name/path where the optional parms are user, password, AUTH and port, so the simplest is: afp://server-name/volume-name/path */ /* if there is a ://, make sure it is preceeded by afp */ if ((p=strstr(toparse,"://"))!=NULL) { q=p-3; if (p<toparse) { if (verbose) printf("URL does not start with afp://\n"); return -1; } if (strncmp(q,"afp",3)!=0) { if (verbose) printf("URL does not start with afp://\n"); return -1; } p+=3; } else { if (verbose) printf("This isn't a URL at all.\n"); return -1; } if (p==NULL) p=(char *)toparse; /* Now split on the first / */ if (sscanf(p,"%[^/]/%[^$]", firstpart, secondpart)!=2) { /* Okay, so there's no volume. */ skip_secondpart=1; } firstpartlen=strlen(firstpart); lastchar=firstpart+firstpartlen-1; /* First part could be something like: user;AUTH=authType:password We'll assume that the breakout is: user; optional user name AUTH=authtype: */ /* Let's see if there's a ';'. q is the end of the username */ if ((p=escape_strchr(firstpart,'@',"@"))) { *p='\0'; p++; } else { skip_earliestpart=1; p=firstpart; } /* p now points to the start of the server name*/ /* square brackets denote a literal ipv6 address */ if (*p == '[' && (q=strchr(p,']'))) { foundv6literal = 1; p++; *q = '\0'; q++; } /* see if we have a port number */ if ((foundv6literal && (q=strchr(q,':'))) || (!foundv6literal && (q=strchr(p,':'))) ) { *q='\0'; q++; if (check_port(q)) return -1; if ((url->port=atoi(q))==0) { if (verbose) printf("Port appears to be zero\n"); return -1; } } snprintf(url->servername,strlen(p)+1,"%s", p); if (check_servername(url->servername)) { if (verbose) printf("This isn't a valid servername\n"); return -1; } if ((p==NULL) || ((strlen(p)+p-1)==lastchar)) { /* afp://server */ } if ((q) && ((strlen(q)+q-1)==lastchar)) { /* afp://server:port */ } /* Earliest part */ if (skip_earliestpart) { p+=strlen(p); goto parse_secondpart; } p=firstpart; /* Now we're left with something like user[;AUTH=uamname][:password] */ /* Look for :password */ if ((q=escape_strrchr(p,':',":"))) { *q='\0'; q++; snprintf(url->password,strlen(q)+1, "%s", q); if (check_password(url->password)) { if (verbose) printf("This isn't a valid passwd\n"); return -1; } } /* Now we're down to user[;AUTH=uamname] */ p=firstpart; if ((q=strstr(p,";AUTH="))) { *q='\0'; q+=6; snprintf(url->uamname,strlen(q)+1,"%s", q); if (check_uamname(url->uamname)) { if (verbose) printf("This isn't a valid uamname\n"); return -1; } } if (strlen(p)>0) { snprintf(url->username,strlen(p)+1,"%s", p); if (check_username(url->username)) { if (verbose) printf("This isn't a valid username\n"); return -1; } } parse_secondpart: if (skip_secondpart) goto done; if (strlen(secondpart)==0) goto done; if (secondpart[strlen(secondpart)]=='/') secondpart[strlen(secondpart)]='\0'; p=secondpart; if ((q=strchr(p,'/'))) { *q='\0'; q++; } snprintf(url->volumename,strlen(p)+1,"%s", p); if (q) { url->path[0]='/'; snprintf(url->path+1,strlen(q)+1, "%s", q); } done: escape_url(url); if (verbose) printf("Successful parsing of URL\n"); return 0; }