Skip to content

CID 1508975: Argument cannot be negative #10228

Closed

Description

@maskit
101int
102get_redis_auth_key(char *retKeyBuff, int buffSize)
103{
104  int retval = 0;
105  // Get the Key
   	1. Condition ssl_param.redis_auth_key_file.length(), taking true branch.
106  if (ssl_param.redis_auth_key_file.length()) {
   	2. negative_return_fn: Function open(ssl_param.redis_auth_key_file.c_str(), 0) returns a negative number.
   	3. assign: Assigning: fd = open(ssl_param.redis_auth_key_file.c_str(), 0).
107    int fd = open(ssl_param.redis_auth_key_file.c_str(), O_RDONLY);
108    struct stat info;
   	
CID 1508975 (#1 of 1): Argument cannot be negative (NEGATIVE_RETURNS)
4. negative_returns: fd is passed to a parameter that cannot be negative. [Note: The source code implementation of the function has been overridden by a builtin model.]
109    if (0 == fstat(fd, &info)) {

Activity

  1. moved this to Todo in ATS v10.0.xon Aug 16, 2023
  2. moved this from Todo to Coverity Defects in ATS v10.0.xon Aug 22, 2023
  3. duke8253 commented on Aug 23, 2023

    @duke8253
    Contributor

    I'm not sure what it means by "fd is passed to a parameter that cannot be negative" for line 109. fstat() is defined as int fstat(int fildes, struct stat *buf); https://man7.org/linux/man-pages/man3/fstat.3p.html .

    Or is it actually saying fd should be checked on line 107?

  4. linked a pull request that will close this issueMake sure open() and read() succeeded #10273on Aug 24, 2023
  5. moved this from Coverity Defects to Done in ATS v10.0.xon Oct 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions