Skip to content

Ekinzie/uninit data fixes#3

Open
ekinzie wants to merge 2 commits intomgranderath:masterfrom
ekinzie:ekinzie/uninit-data-fixes
Open

Ekinzie/uninit data fixes#3
ekinzie wants to merge 2 commits intomgranderath:masterfrom
ekinzie:ekinzie/uninit-data-fixes

Conversation

@ekinzie
Copy link

@ekinzie ekinzie commented Jan 21, 2020

Hi, here are a couple of trivial changes I made to get the tavern-ci tests to pass on my systems. Both deal with uninitialized memory. I tested with openwrt 18.06 on arm64.

For a vector v of length n, element v[n] is not guaranteed to be NULL
as vector_grow does not clear newly allocated memory.  Get the length
of the vector instead of checking for a NULL element.  This (a) fixes a
segfault when the unitialized pointer value is non-null and (b) correctly
detects the root node so that a POST to /restconf/data creates a new
top-level node.

Signed-off-by: Eric Kinzie <ekinzie@labn.net>
Initialize the key_out string with a NULL at the beginning so that
strcat() and strlen() are not confused by whatever uninitialized non-zero
data happens to be there.  This avoids appending =<key> when no key should
be output (and it contains garbage).  It also fixes the formatting of keys
when strcat() has appended the first key after some uninitialized data.

example from tavern-ci output:

ERROR    tavern.response.base:base.py:51 Value mismatch in headers: Key mismatch: (expected["location"] = 'https://192.168.1.40/cgi-bin/restconf/data/restconf-example:course/instructors' (type = <class 'tavern.util.dict_util.format_keys.<locals>.InnerFormattedString'>), actual["location"] = 'https://192.168.1.40/cgi-bin/restconf/data/restconf-example:course/instructors=*Ò¶ÿÿ' (type = <class '
str'>))

Signed-off-by: Eric Kinzie <ekinzie@labn.net>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants