• Philip Chimento's avatar
    context: Fix gjs_context_eval() for non-zero-terminated strings · 870b1942
    Philip Chimento authored
    Calling gjs_context_eval() with a non-zero-terminated string has
    apparently been broken for quite a long time. I guess nobody ever does
    that.
    
    This is a surprisingly complicated fix for a simple-sounding problem.
    The complication is due to the passed-in strlen being ignored in more
    than one place: both in gjs_strip_unix_shebang() and in the code that
    converts UTF-8 to UTF-16.
    
    In addition, gjs_strip_unix_shebang() would access invalid memory if
    given a 1-length string or a non-zero-terminated string.
    
    We fix the UTF-16 conversion code, and replace gjs_strip_unix_shebang()
    with a safer version using C++ strings (which we have anyway after
    converting to UTF-16.) This new function, gjs_unix_shebang_len(),
    returns the offset that must be added to the string's starting position,
    in order to skip the shebang line.
    
    It would be better in the future to return a std::u16string_view from
    gjs_unix_shebang_len(), but that is not yet available in C++14.
    
    This bug was found by compiling with -Wunused-parameter!
    870b1942
Name
Last commit
Last update
..
arg.cpp Loading commit data...
arg.h Loading commit data...
boxed.cpp Loading commit data...
boxed.h Loading commit data...
closure.cpp Loading commit data...
closure.h Loading commit data...
enumeration.cpp Loading commit data...
enumeration.h Loading commit data...
foreign.cpp Loading commit data...
foreign.h Loading commit data...
function.cpp Loading commit data...
function.h Loading commit data...
fundamental.cpp Loading commit data...
fundamental.h Loading commit data...
gerror.cpp Loading commit data...
gerror.h Loading commit data...
gjs_gi_probes.d Loading commit data...
gjs_gi_trace.h Loading commit data...
gobject.cpp Loading commit data...
gobject.h Loading commit data...
gtype.cpp Loading commit data...
gtype.h Loading commit data...
interface.cpp Loading commit data...
interface.h Loading commit data...
ns.cpp Loading commit data...
ns.h Loading commit data...
object.cpp Loading commit data...
object.h Loading commit data...
param.cpp Loading commit data...
param.h Loading commit data...
private.cpp Loading commit data...
private.h Loading commit data...
repo.cpp Loading commit data...
repo.h Loading commit data...
toggle.cpp Loading commit data...
toggle.h Loading commit data...
union.cpp Loading commit data...
union.h Loading commit data...
value.cpp Loading commit data...
value.h Loading commit data...
wrapperutils.cpp Loading commit data...
wrapperutils.h Loading commit data...