File tree Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Expand file tree Collapse file tree 1 file changed +10
-3
lines changed Original file line number Diff line number Diff line change @@ -815,6 +815,12 @@ int InitializeStreams() {
815815 return 0 ;
816816}
817817
818+ template <typename T>
819+ std::make_unsigned_t <T> get_as_unsigned (T v) {
820+ using UnsignedT = std::make_unsigned_t <T>;
821+ return static_cast <UnsignedT>(v);
822+ }
823+
818824} // end namespace internal
819825
820826void MaybeReenterWithoutASLR (int /* argc*/ , char ** argv) {
@@ -829,11 +835,12 @@ void MaybeReenterWithoutASLR(int /*argc*/, char** argv) {
829835 if (curr_personality == -1 ) return ;
830836
831837 // If ASLR is already disabled, we have nothing more to do.
832- if (curr_personality & ADDR_NO_RANDOMIZE) return ;
838+ if (internal::get_as_unsigned ( curr_personality) & ADDR_NO_RANDOMIZE) return ;
833839
834840 // Try to change the personality to disable ASLR.
835- const auto prev_personality = personality (
836- static_cast <unsigned long >(curr_personality) | ADDR_NO_RANDOMIZE);
841+ const auto proposed_personality =
842+ internal::get_as_unsigned (curr_personality) | ADDR_NO_RANDOMIZE;
843+ const auto prev_personality = personality (proposed_personality);
837844
838845 // Have we failed to change the personality? That may happen.
839846 if (prev_personality == -1 ) return ;
You can’t perform that action at this time.
0 commit comments