Trac issueshttps://gitlab.torproject.org/legacy/trac/-/issues2020-06-13T15:40:52Zhttps://gitlab.torproject.org/legacy/trac/-/issues/30225Run clang's scan-build in Tor's CI2020-06-13T15:40:52ZteorRun clang's scan-build in Tor's CIThere can be a few days between merging and a coverity build.
So we could also use clang's scan-build in CI, to get immediate feedback.
Code that passes scan-build should have less coverity defects.There can be a few days between merging and a coverity build.
So we could also use clang's scan-build in CI, to get immediate feedback.
Code that passes scan-build should have less coverity defects.Tor: unspecifiedhttps://gitlab.torproject.org/legacy/trac/-/issues/28881Initialize addr in parse_port_config2020-06-13T15:35:47ZNick MathewsonInitialize addr in parse_port_configScan-build can't convince itself that the "addr" variable in parse_port_config() is always initialized before use.Scan-build can't convince itself that the "addr" variable in parse_port_config() is always initialized before use.Tor: 0.3.5.x-finalNick MathewsonNick Mathewsonhttps://gitlab.torproject.org/legacy/trac/-/issues/21497Fix scan-build warnings: memory accesses2020-06-13T15:06:27ZteorFix scan-build warnings: memory accessesThese should all be ok.
router_get_hash_impl_helper:
```
- if (start != s && *(start-1) != '\n') {
+ if (start > s && *(start-1) != '\n') {
```
read_escaped_data:
This is just a false positive, we should add ignore comments:
```
if (...These should all be ok.
router_get_hash_impl_helper:
```
- if (start != s && *(start-1) != '\n') {
+ if (start > s && *(start-1) != '\n') {
```
read_escaped_data:
This is just a false positive, we should add ignore comments:
```
if (n_to_copy && *(next-1) == '\r')
```
format_win_cmdline_argument:
These are just false positives, we should add ignore comments around the trailing quote and terminator assignments:
```
formatted_arg[i++] = '"';
```
```
formatted_arg[i] = '\0';
```
unescape_string:
These are just false positives, we should add ignore comments:
```
*out++ = *cp++;
```
```
*out++ = cp[1];
```
```
*out++ = (char)n;
```
```
*out++ = ((x1<<4) + x2);
```
```
case 'n': *out++ = '\n'; cp += 2; break;
case 'r': *out++ = '\r'; cp += 2; break;
case 't': *out++ = '\t'; cp += 2; break;
```
```
*out = '\0';
```
tor_escape_str_for_pt_args:
These are just false positives, we should add ignore comments:
```
*new_cp = '\0'; /* NUL-terminate the new string */
```
```
*new_cp++ = *string++;
```
process_environment_make:
This is just a false positive, we should add ignore comments:
```
memcpy(cp, s, slen+1);
```Tor: unspecifiedhttps://gitlab.torproject.org/legacy/trac/-/issues/21496Check string passed to extrainfo_parse_entry_from_string2020-06-13T15:06:27ZteorCheck string passed to extrainfo_parse_entry_from_stringscan-build reports the following out of bounds access, because it doesn't know that s is always non-NULL. But we should guard against it being NULL.
extrainfo_parse_entry_from_string:
```
+ if (BUG(!s))
+ return;
while (end > s+2...scan-build reports the following out of bounds access, because it doesn't know that s is always non-NULL. But we should guard against it being NULL.
extrainfo_parse_entry_from_string:
```
+ if (BUG(!s))
+ return;
while (end > s+2 && *(end-1) == '\n' && *(end-2) == '\n')
```Tor: 0.3.1.x-finalNick MathewsonNick Mathewsonhttps://gitlab.torproject.org/legacy/trac/-/issues/21495Fix scan-build warning: true and false branches are identical2020-06-13T15:06:26ZteorFix scan-build warning: true and false branches are identicalThis is fine, we can rewrite it, or tell scan-build to ignore it:
dirvote_get_intermediate_param_value:
```
else if (BUG(n_found > 1))
return default_val;
else
return default_val;
```
I blame boolean macros with side-effects.This is fine, we can rewrite it, or tell scan-build to ignore it:
dirvote_get_intermediate_param_value:
```
else if (BUG(n_found > 1))
return default_val;
else
return default_val;
```
I blame boolean macros with side-effects.Tor: 0.3.2.x-finalNick MathewsonNick Mathewsonhttps://gitlab.torproject.org/legacy/trac/-/issues/21494Fix scan-build warnings about assigning to char**2020-06-13T15:06:26ZteorFix scan-build warnings about assigning to char**scan-build complains about:
tor_check_port_forwarding:
```
const char **argv; /* cli arguments */
...
argv = tor_calloc(args_n, sizeof(char *));
```
and:
process_environment_make:
```
process_environment_t *env = tor_malloc_zero(sizeof(p...scan-build complains about:
tor_check_port_forwarding:
```
const char **argv; /* cli arguments */
...
argv = tor_calloc(args_n, sizeof(char *));
```
and:
process_environment_make:
```
process_environment_t *env = tor_malloc_zero(sizeof(process_environment_t));
...
env->unixoid_environment_block = tor_calloc(n_env_vars + 1, sizeof(char *));
```
This is fine, and maybe there's a cast or magic comment we could use to make the warnings go away.Tor: unspecified