• Thomas Haller's avatar
    libnm: cleanup _nm_utils_parse_tc_handle() · d3666ab9
    Thomas Haller authored
    - g_ascii_strtoll() accepts leading spaces, but it leaves
      the end pointer at the first space after the digit. That means,
      we accepted "1: 0" but not "1 :0". We should either consistently
      accept spaces around the digits/colon or reject it.
    
    - g_ascii_strtoll() accepts "\v" as a space (just like `man 3 isspace`
      comments that "\v" is a space in C and POSIX locale.
      For some reasons (unknown to me) g_ascii_isspace() does not treat
      "\v" as space. And neither does NM_ASCII_SPACES and
      nm_str_skip_leading_spaces().
      We should be consistent about what we consider spaces and what not.
      It's already odd to accept '\n' as spaces here, but well, lets do
      it for the sake of consistency (so that it matches with our
      understanding of ASCII spaces, albeit not POSIX's).
    
    - don't use bogus error domains in "g_set_error (error, 1, 0, ..."
      That is a bug and we have NM_UTILS_ERROR exactly for error instances
      with unspecified domain and code.
    
    - as before, accept a trailing ":" with omitted minor number.
    
    - reject all unexpected characters. strtoll() accepts '+' / '-'
      and a "0x" prefix of the numbers (and leading POSIX spaces). Be
      strict here and only accepts NM_ASCII_SPACES, ':', and hexdigits.
      In particular, don't accept the "0x" prefix.
    
    This parsing would be significantly simpler to implement, if we could
    just strdup() the string, split the string at the colon delimiter and
    use _nm_utils_ascii_str_to_int64() which gets leading/trailing spaces
    right. But let's save the "overhead" of an additional alloc.
    
    (cherry picked from commit cc9f0716)
    d3666ab9
Name
Last commit
Last update
clients Loading commit data...
contrib Loading commit data...
data Loading commit data...
dispatcher Loading commit data...
docs Loading commit data...
examples Loading commit data...
introspection Loading commit data...
libnm Loading commit data...
libnm-core Loading commit data...
libnm-glib Loading commit data...
libnm-util Loading commit data...
m4 Loading commit data...
man Loading commit data...
po Loading commit data...
shared Loading commit data...
src Loading commit data...
tools Loading commit data...
vapi Loading commit data...
.dir-locals.el Loading commit data...
.gitignore Loading commit data...
.gitlab-ci.yml Loading commit data...
.mailmap Loading commit data...
.travis.yml Loading commit data...
AUTHORS Loading commit data...
CONTRIBUTING Loading commit data...
COPYING Loading commit data...
ChangeLog Loading commit data...
MAINTAINERS Loading commit data...
Makefile.am Loading commit data...
Makefile.examples Loading commit data...
Makefile.glib Loading commit data...
Makefile.vapigen Loading commit data...
NEWS Loading commit data...
NetworkManager.pc.in Loading commit data...
README Loading commit data...
TODO Loading commit data...
autogen.sh Loading commit data...
config-extra.h.meson Loading commit data...
config.h.meson Loading commit data...
configure.ac Loading commit data...
linker-script-binary.ver Loading commit data...
linker-script-devices.ver Loading commit data...
linker-script-settings.ver Loading commit data...
meson.build Loading commit data...
meson_options.txt Loading commit data...
valgrind.suppressions Loading commit data...
zanata.xml Loading commit data...