-
Notifications
You must be signed in to change notification settings - Fork 1
/
ngx_gp_parse.c
73 lines (50 loc) · 1.28 KB
/
ngx_gp_parse.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/*
* Copyright (C) jh, [email protected]
*/
#include <ngx_config.h>
#include <ngx_core.h>
#include <ngx_event.h>
#include "ngx_gp.h"
/*
Flash Player sends:
"<policy-file-request/>\x00"
We reply:
"<?xml version=\"1.0\"?>" CRLF
"<cross-domain-policy>" CRLF
"<site-control permitted-cross-domain-policies=\"all\"/>" CRLF
[multiple] : "<allow-access-from domain=\"...\" to-ports=\"...\" />" CRLF
"</cross-domain-policy>" CRLF
*/
static u_char flash_request[] = "<policy-file-request/>"; /* including the terminal \0 */
ngx_int_t
ngx_gp_flash_policy_parse_command(ngx_gp_session_t *s)
{
u_char ch, *p, *c;
for (p = s->buffer->pos; p < s->buffer->last; p++) {
ch = *p;
if (ch == '\0') {
c = s->buffer->start;
if (p - c == sizeof(flash_request)) {
if (ngx_memcmp(c, flash_request, sizeof(flash_request)) == 0)
{
s->command = NGX_FLASH_POLICY_REQUEST;
goto done;
} else {
goto invalid;
}
} else {
goto invalid;
}
}
}
s->buffer->pos = p;
s->state = 0;
return NGX_AGAIN;
done:
s->buffer->pos = p + 1;
s->state = 0;
return NGX_OK;
invalid:
s->state = 0;
return NGX_GP_PARSE_INVALID_COMMAND;
}