This repository has been archived by the owner on May 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
271 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package libc | ||
|
||
import unsafe "unsafe" | ||
|
||
func _cgos_dummy_clearenv(old *int8, new *int8) { | ||
} | ||
func Clearenv() int32 { | ||
var e **int8 = X__environ | ||
X__environ = (**int8)(nil) | ||
if e != nil { | ||
for *e != nil { | ||
__env_rm_add(*func() (_cgo_ret **int8) { | ||
_cgo_addr := &e | ||
_cgo_ret = *_cgo_addr | ||
*(*uintptr)(unsafe.Pointer(_cgo_addr)) += 8 | ||
return | ||
}(), nil) | ||
} | ||
} | ||
return int32(0) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package libc | ||
|
||
import unsafe "unsafe" | ||
|
||
func _cgos_dummy_putenv(old *int8, new *int8) { | ||
} | ||
func __putenv(s *int8, l uint64, r *int8) int32 { | ||
var i uint64 = uint64(0) | ||
if X__environ != nil { | ||
for e := (**int8)(X__environ); *e != nil; func() uint64 { | ||
*(*uintptr)(unsafe.Pointer(&e)) += 8 | ||
return func() (_cgo_ret uint64) { | ||
_cgo_addr := &i | ||
_cgo_ret = *_cgo_addr | ||
*_cgo_addr++ | ||
return | ||
}() | ||
}() { | ||
if !(Strncmp(s, *e, l+uint64(1)) != 0) { | ||
var tmp *int8 = *e | ||
*e = s | ||
__env_rm_add(tmp, r) | ||
return int32(0) | ||
} | ||
} | ||
} | ||
var newenv **int8 | ||
if uintptr(unsafe.Pointer(X__environ)) == uintptr(unsafe.Pointer(_cgos_oldenv_putenv)) { | ||
newenv = (**int8)(Realloc(unsafe.Pointer(_cgos_oldenv_putenv), 8*(i+uint64(2)))) | ||
if !(newenv != nil) { | ||
goto oom | ||
} | ||
} else { | ||
newenv = (**int8)(Malloc(8 * (i + uint64(2)))) | ||
if !(newenv != nil) { | ||
goto oom | ||
} | ||
if i != 0 { | ||
Memcpy(unsafe.Pointer(newenv), unsafe.Pointer(X__environ), 8*i) | ||
} | ||
Free(unsafe.Pointer(_cgos_oldenv_putenv)) | ||
} | ||
*(**int8)(unsafe.Pointer(uintptr(unsafe.Pointer(newenv)) + uintptr(i)*8)) = s | ||
*(**int8)(unsafe.Pointer(uintptr(unsafe.Pointer(newenv)) + uintptr(i+uint64(1))*8)) = (*int8)(nil) | ||
X__environ = func() (_cgo_ret **int8) { | ||
_cgo_addr := &_cgos_oldenv_putenv | ||
*_cgo_addr = newenv | ||
return *_cgo_addr | ||
}() | ||
if r != nil { | ||
__env_rm_add(nil, r) | ||
} | ||
return int32(0) | ||
oom: | ||
Free(unsafe.Pointer(r)) | ||
return -1 | ||
} | ||
|
||
var _cgos_oldenv_putenv **int8 | ||
|
||
func Putenv(s *int8) int32 { | ||
var l uint64 = uint64(uintptr(unsafe.Pointer(__strchrnul(s, '='))) - uintptr(unsafe.Pointer(s))) | ||
if !(l != 0) || !(*(*int8)(unsafe.Pointer(uintptr(unsafe.Pointer(s)) + uintptr(l))) != 0) { | ||
return Unsetenv(s) | ||
} | ||
return __putenv(s, l, nil) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package libc | ||
|
||
func Secure_getenv(name *int8) *int8 { | ||
return func() *int8 { | ||
if int32(__libc.secure) != 0 { | ||
return nil | ||
} else { | ||
return Getenv(name) | ||
} | ||
}() | ||
} |
Oops, something went wrong.