#522 Uninitialized use of 'ret' in get_gid() of sss_useradd
Closed: Fixed None Opened 13 years ago by sgallagh.

From Coverity:

   62/* Returns a gid for a given groupname. If a numerical gid
   63 * is given, returns that as integer (rationale: shadow-utils)
   64 * On error, returns -EINVAL
   65 */
   66static int get_gid(struct tools_ctx *tctx, const char *groupname)
   67{
   68    char *end_ptr;
Declaring variable "ret" without initializer.
   69    int ret;
   70
   71    errno = 0;
   72    tctx->octx->gid = strtoul(groupname, &end_ptr, 10);
At conditional (1): "groupname == NULL" taking the false branch.
At conditional (2): "*end_ptr != 0" taking the false branch.
At conditional (3): "*__errno_location() != 0" taking the false branch.
At conditional (4): "tctx->octx->gid == 0U" taking the false branch.
   73    if (groupname == '\0' || *end_ptr != '\0' ||
   74        errno != 0 || tctx->octx->gid == 0) {
   75        /* Does not look like a gid - find the group name */
   76
   77        ret = sysdb_getgrnam(tctx->octx, tctx->sysdb,
   78                             tctx->octx->domain, groupname,
   79                             get_gid_callback, tctx);
   80        if (ret != EOK) {
   81            DEBUG(1, ("sysdb_getgrnam failed: %d\n", ret));
   82            goto done;
   83        }
   84
   85        tctx->error = EOK;
   86        tctx->octx->gid = 0;
   87        while ((tctx->error == EOK) && (tctx->octx->gid == 0)) {
   88            tevent_loop_once(tctx->ev);
   89        }
   90
   91        if (tctx->error) {
   92            DEBUG(1, ("sysdb_getgrnam failed: %d\n", ret));
   93            goto done;
   94        }
   95    }
   96
   97done:
Using uninitialized value "ret".
   98    return ret;
   99}

This function just completely mishandles ret.


Fields changed

milestone: NEEDS_TRIAGE => SSSD 1.2.0

Fields changed

milestone: SSSD 1.2.0 => SSSD 1.2.1

Fields changed

keywords: => coverity

Fields changed

status: new => assigned

Fixed by 0b2d2be

fixedin: => 1.2.1
resolution: => fixed
status: assigned => closed

Fields changed

rhbz: => 0

Metadata Update from @sgallagh:
- Issue assigned to jhrozek
- Issue set to the milestone: SSSD 1.2.1

7 years ago

SSSD is moving from Pagure to Github. This means that new issues and pull requests
will be accepted only in SSSD's github repository.

This issue has been cloned to Github and is available here:
- https://github.com/SSSD/sssd/issues/1564

If you want to receive further updates on the issue, please navigate to the github issue
and click on subscribe button.

Thank you for understanding. We apologize for all inconvenience.

Login to comment on this ticket.

Metadata