Skip to content

Commit 407f604

Browse files
authored
Merge pull request #2716 from xrmx/second-batch-2.0.29
Second batch of backports for 2.0.29
2 parents f060689 + 49a37c8 commit 407f604

File tree

6 files changed

+31
-5
lines changed

6 files changed

+31
-5
lines changed

core/reader.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ char *uwsgi_request_body_readline(struct wsgi_request *wsgi_req, ssize_t hint, s
283283
}
284284

285285
// no line found, let's return all
286-
*rlen = wsgi_req->post_readline_size - wsgi_req->post_readline_pos;
286+
*rlen = wsgi_req->post_readline_watermark - wsgi_req->post_readline_pos;
287287
char *buf = wsgi_req->post_readline_buf + wsgi_req->post_readline_pos;
288288
wsgi_req->post_readline_pos = 0;
289289
return buf;

t/core/readline/__init__.py

Whitespace-only changes.

t/core/readline/app.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/python3
2+
# uwsgi --plugin python,http --http 0.0.0.0:8000 -w app
3+
4+
from werkzeug.wrappers import Request, Response
5+
6+
7+
def application(env, start_response):
8+
request = Request(env)
9+
lines = b""
10+
while True:
11+
line = request.stream.readline()
12+
if not line:
13+
break;
14+
lines += line
15+
response = Response(lines)
16+
return response(env, start_response)

t/core/readline/client.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import requests
2+
3+
headers = {'Content-Type': 'application/octet-stream'}
4+
data = '\n'.join(['{:04}'.format(i) for i in range(1001)] + ['final'])
5+
6+
r = requests.post("http://127.0.0.1:8000", data=data, headers=headers)
7+
8+
assert r.text == data

t/core/readline/requirements.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
requests
2+
Werkzeug

uwsgiconfig.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -535,7 +535,7 @@ def build_uwsgi(uc, print_only=False, gcll=None):
535535
gcc_list.append('%s/%s' % (path, cfile))
536536
for bfile in up.get('BINARY_LIST', []):
537537
try:
538-
binary_link_cmd = "ld -r -b binary -o %s/%s.o %s/%s" % (path, bfile[1], path, bfile[1])
538+
binary_link_cmd = "ld -z noexecstack -r -b binary -o %s/%s.o %s/%s" % (path, bfile[1], path, bfile[1])
539539
print(binary_link_cmd)
540540
if subprocess.call(binary_link_cmd, shell=True) != 0:
541541
raise Exception('unable to link binary file')
@@ -1150,7 +1150,7 @@ def get_gcll(self):
11501150
if not self.embed_config:
11511151
self.embed_config = self.get('embed_config')
11521152
if self.embed_config:
1153-
binary_link_cmd = "ld -r -b binary -o %s.o %s" % (binarize(self.embed_config), self.embed_config)
1153+
binary_link_cmd = "ld -z noexecstack -r -b binary -o %s.o %s" % (binarize(self.embed_config), self.embed_config)
11541154
print(binary_link_cmd)
11551155
subprocess.call(binary_link_cmd, shell=True)
11561156
self.cflags.append("-DUWSGI_EMBED_CONFIG=_binary_%s_start" % binarize(self.embed_config))
@@ -1169,7 +1169,7 @@ def get_gcll(self):
11691169
for directory, directories, files in os.walk(ef):
11701170
for f in files:
11711171
fname = "%s/%s" % (directory, f)
1172-
binary_link_cmd = "ld -r -b binary -o %s.o %s" % (binarize(fname), fname)
1172+
binary_link_cmd = "ld -z noexecstack -r -b binary -o %s.o %s" % (binarize(fname), fname)
11731173
print(binary_link_cmd)
11741174
subprocess.call(binary_link_cmd, shell=True)
11751175
if symbase:
@@ -1179,7 +1179,7 @@ def get_gcll(self):
11791179
subprocess.call(objcopy_cmd, shell=True)
11801180
binary_list.append(binarize(fname))
11811181
else:
1182-
binary_link_cmd = "ld -r -b binary -o %s.o %s" % (binarize(ef), ef)
1182+
binary_link_cmd = "ld -z noexecstack -r -b binary -o %s.o %s" % (binarize(ef), ef)
11831183
print(binary_link_cmd)
11841184
subprocess.call(binary_link_cmd, shell=True)
11851185
binary_list.append(binarize(ef))

0 commit comments

Comments
 (0)