Changeset 4137
- Timestamp:
- 12/17/10 17:58:19 (13 years ago)
- Location:
- trunk
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/oscam-http-helpers.c
r4031 r4137 390 390 } else 391 391 #endif 392 { 393 buf[0]='\0'; 394 int len=0; 395 while (fgets(buf+len, num-len-1, f)) { 396 if (buf[0+len] == '\r' && buf[1+len] == '\n') break; 397 len=strlen(buf); 398 } 399 return len; 400 } 392 return read(fileno(f), buf, num); 401 393 } 402 394 -
trunk/oscam-http.c
r4129 r4137 2559 2559 } 2560 2560 2561 void webif_parse_request(struct uriparams *params, char *pch) { 2562 /* Parse url parameters; parsemode = 1 means parsing next param, parsemode = -1 parsing next 2563 value; pch2 points to the beginning of the currently parsed string, pch is the current position */ 2564 2565 char *pch2; 2566 int parsemode = 1; 2567 2568 pch2=pch; 2569 while(pch[0] != '\0') { 2570 if((parsemode == 1 && pch[0] == '=') || (parsemode == -1 && pch[0] == '&')) { 2571 pch[0] = '\0'; 2572 urldecode(pch2); 2573 if(parsemode == 1) { 2574 if(params->paramcount >= MAXGETPARAMS) break; 2575 ++params->paramcount; 2576 params->params[params->paramcount-1] = pch2; 2577 } else { 2578 params->values[params->paramcount-1] = pch2; 2579 } 2580 parsemode = -parsemode; 2581 pch2 = pch + 1; 2582 } 2583 ++pch; 2584 } 2585 /* last value wasn't processed in the loop yet... */ 2586 if(parsemode == -1 && params->paramcount <= MAXGETPARAMS) { 2587 urldecode(pch2); 2588 params->values[params->paramcount-1] = pch2; 2589 } 2590 } 2591 2561 2592 int process_request(FILE *f, struct in_addr in) { 2562 2593 … … 2621 2652 } 2622 2653 2623 char buf[ 4096];2654 char buf[10240]; 2624 2655 char *tmp; 2625 2656 … … 2631 2662 char *protocol; 2632 2663 char *pch; 2633 char *pch2;2634 2664 /* List of possible pages */ 2635 2665 char *pages[]= { … … 2658 2688 int pgidx = -1; 2659 2689 int i; 2660 int parsemode = 1;2661 2690 struct uriparams params; 2662 2691 params.paramcount = 0; … … 2665 2694 char *saveptr1=NULL; 2666 2695 int n; 2667 if ((n=webif_read(buf, sizeof(buf) , f)) <= 0) {2696 if ((n=webif_read(buf, sizeof(buf)-1, f)) <= 0) { 2668 2697 cs_debug("webif read error %d", n); 2669 2698 return -1; 2670 2699 } 2700 buf[n]='\0'; 2671 2701 2672 2702 method = strtok_r(buf, " ", &saveptr1); … … 2689 2719 } 2690 2720 2691 /* Parse url parameters; parsemode = 1 means parsing next param, parsemode = -1 parsing next 2692 value; pch2 points to the beginning of the currently parsed string, pch is the current position */ 2693 pch2=pch; 2694 while(pch[0] != '\0') { 2695 if((parsemode == 1 && pch[0] == '=') || (parsemode == -1 && pch[0] == '&')) { 2696 pch[0] = '\0'; 2697 urldecode(pch2); 2698 if(parsemode == 1) { 2699 if(params.paramcount >= MAXGETPARAMS) break; 2700 ++params.paramcount; 2701 params.params[params.paramcount-1] = pch2; 2702 } else { 2703 params.values[params.paramcount-1] = pch2; 2704 } 2705 parsemode = -parsemode; 2706 pch2 = pch + 1; 2707 } 2708 ++pch; 2709 } 2710 /* last value wasn't processed in the loop yet... */ 2711 if(parsemode == -1 && params.paramcount <= MAXGETPARAMS) { 2712 urldecode(pch2); 2713 params.values[params.paramcount-1] = pch2; 2714 } 2721 webif_parse_request(¶ms, pch); 2715 2722 2716 2723 if(strlen(cfg->http_user) == 0 || strlen(cfg->http_pwd) == 0) authok = 1; … … 2718 2725 2719 2726 char *str1, *saveptr=NULL; 2727 2720 2728 for (str1=strtok_r(tmp, "\n", &saveptr); str1; str1=strtok_r(NULL, "\n", &saveptr)) { 2721 if (str1[0] == '\r' && str1[1] == '\n') break; 2722 else if(authok == 0 && strlen(str1) > 50 && strncmp(str1, "Authorization:", 14) == 0 && strstr(str1, "Digest") != NULL) { 2729 if (strlen(str1)==1) { 2730 if (strcmp(method, "POST")==0) { 2731 webif_parse_request(¶ms, str1+2); 2732 } 2733 break; 2734 } 2735 if(authok == 0 && strlen(str1) > 50 && strncmp(str1, "Authorization:", 14) == 0 && strstr(str1, "Digest") != NULL) { 2723 2736 authok = check_auth(str1, method, path, expectednonce); 2724 2737 } -
trunk/oscam-http.h
r4130 r4137 318 318 ##TPLFILEMENU##\n\ 319 319 <BR><BR>##SDEBUG####SLOG####SCLEAR##<BR>##FILTER##\n\ 320 <FORM ACTION=\"files.html\" method=\" get\">\n\320 <FORM ACTION=\"files.html\" method=\"post\">\n\ 321 321 <INPUT TYPE=\"hidden\" NAME=\"part\" VALUE=\"##PART##\">\n\ 322 322 <TEXTAREA NAME=\"filecontent\" CLASS=\"editor\">##FILECONTENT##</TEXTAREA><BR>##WRITEPROTECTION##<BR>\n\ -
trunk/oscam.c
r4136 r4137 3123 3123 break; 3124 3124 case 'x': 3125 #ifdef COOL 3125 3126 cooldebug = 1; 3127 #endif 3126 3128 break; 3127 3129 case 'h':
Note:
See TracChangeset
for help on using the changeset viewer.