Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
P
Pyston
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
Pyston
Commits
6c9bb239
Commit
6c9bb239
authored
Sep 04, 2014
by
Kevin Modzelewski
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #147 from undingen/mem_corruption
Fix a memory corruption in posix.urandom
parents
6eaa7283
fa4bf00c
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
14 additions
and
1 deletion
+14
-1
src/core/threading.cpp
src/core/threading.cpp
+1
-0
src/runtime/builtin_modules/builtins.cpp
src/runtime/builtin_modules/builtins.cpp
+2
-0
src/runtime/builtin_modules/posix.cpp
src/runtime/builtin_modules/posix.cpp
+2
-1
src/runtime/long.cpp
src/runtime/long.cpp
+8
-0
src/runtime/long.h
src/runtime/long.h
+1
-0
No files found.
src/core/threading.cpp
View file @
6c9bb239
...
...
@@ -345,6 +345,7 @@ void registerMainThread() {
current_threads
[
gettid
()]
=
new
ThreadStateInternal
(
find_stack
(),
pthread_self
());
struct
sigaction
act
;
memset
(
&
act
,
0
,
sizeof
(
act
));
act
.
sa_flags
=
SA_SIGINFO
;
act
.
sa_sigaction
=
_thread_context_dump
;
struct
sigaction
oldact
;
...
...
src/runtime/builtin_modules/builtins.cpp
View file @
6c9bb239
...
...
@@ -90,6 +90,8 @@ extern "C" Box* abs_(Box* x) {
}
else
if
(
x
->
cls
==
float_cls
)
{
double
d
=
static_cast
<
BoxedFloat
*>
(
x
)
->
d
;
return
boxFloat
(
d
>=
0
?
d
:
-
d
);
}
else
if
(
x
->
cls
==
long_cls
)
{
return
longAbs
(
static_cast
<
BoxedLong
*>
(
x
));
}
else
{
RELEASE_ASSERT
(
0
,
"%s"
,
getTypeName
(
x
)
->
c_str
());
}
...
...
src/runtime/builtin_modules/posix.cpp
View file @
6c9bb239
...
...
@@ -39,7 +39,7 @@ Box* urandom(Box* _n) {
int
fd
=
::
open
(
"/dev/urandom"
,
O_RDONLY
);
RELEASE_ASSERT
(
fd
>
0
,
""
);
BoxedString
*
r
=
static_cast
<
BoxedString
*>
(
PyString_FromStringAndSize
(
NULL
,
sizeof
(
n
)
));
BoxedString
*
r
=
static_cast
<
BoxedString
*>
(
PyString_FromStringAndSize
(
NULL
,
n
));
RELEASE_ASSERT
(
r
,
""
);
char
*
buf
=
PyString_AsString
(
r
);
...
...
@@ -49,6 +49,7 @@ Box* urandom(Box* _n) {
assert
(
this_read
>
0
);
total_read
+=
this_read
;
}
::
close
(
fd
);
return
r
;
}
...
...
src/runtime/long.cpp
View file @
6c9bb239
...
...
@@ -224,6 +224,14 @@ Box* longNeg(BoxedLong* v1) {
return
r
;
}
Box
*
longAbs
(
BoxedLong
*
v1
)
{
assert
(
isSubclass
(
v1
->
cls
,
long_cls
));
BoxedLong
*
r
=
new
BoxedLong
(
long_cls
);
mpz_init
(
r
->
n
);
mpz_abs
(
r
->
n
,
v1
->
n
);
return
r
;
}
Box
*
longAdd
(
BoxedLong
*
v1
,
Box
*
_v2
)
{
if
(
!
isSubclass
(
v1
->
cls
,
long_cls
))
raiseExcHelper
(
TypeError
,
"descriptor '__add__' requires a 'long' object but received a '%s'"
,
...
...
src/runtime/long.h
View file @
6c9bb239
...
...
@@ -37,6 +37,7 @@ extern "C" Box* createLong(const std::string* s);
extern
"C"
BoxedLong
*
boxLong
(
int64_t
n
);
Box
*
longNeg
(
BoxedLong
*
lhs
);
Box
*
longAbs
(
BoxedLong
*
v1
);
Box
*
longAdd
(
BoxedLong
*
lhs
,
Box
*
rhs
);
Box
*
longSub
(
BoxedLong
*
lhs
,
Box
*
rhs
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment