VirtualBox

Changeset 95327 in vbox for trunk/src


Ignore:
Timestamp:
Jun 21, 2022 2:40:37 PM (3 years ago)
Author:
vboxsync
Message:

GA/pam_vbox.cpp: Fixed leak in pam_vbox_read_prop.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/common/pam/pam_vbox.cpp

    r94184 r95327  
    417417     * hope.  Actually this should never go wrong, as we are generous
    418418     * enough with buffer space. */
    419     for (unsigned i = 0; i < 10; i++)
     419    for (unsigned i = 0; ; i++)
    420420    {
    421421        void *pvTmpBuf = RTMemRealloc(pvBuf, cbBuf);
     
    426426                                     &pszValTemp, &u64Timestamp, &pszFlags,
    427427                                     &cbBuf);
    428         }
    429         else
    430             rc = VERR_NO_MEMORY;
    431 
    432         switch (rc)
    433         {
    434             case VERR_BUFFER_OVERFLOW:
     428            if (rc == VERR_BUFFER_OVERFLOW && i < 10)
    435429            {
    436430                /* Buffer too small, try it with a bigger one next time. */
     
    438432                continue; /* Try next round. */
    439433            }
    440 
    441             default:
    442                 break;
    443         }
    444 
    445         /* Everything except VERR_BUFFER_OVERLOW makes us bail out ... */
    446         break;
     434        }
     435        else
     436            rc = VERR_NO_MEMORY;
     437        break; /* Everything except VERR_BUFFER_OVERFLOW makes us bail out ... */
    447438    }
    448439
     
    457448                /* If we want a property which is read-only on the guest
    458449                 * and it is *not* marked as such, deny access! */
    459                 pam_vbox_error(hPAM, "pam_vbox_read_prop: key \"%s\" should be read-only on guest but it is not\n",
    460                                pszKey);
     450                pam_vbox_error(hPAM, "pam_vbox_read_prop: key \"%s\" should be read-only on guest but it is not\n", pszKey);
    461451                rc = VERR_ACCESS_DENIED;
    462452            }
     
    464454        else /* No flags, no access! */
    465455        {
    466             pam_vbox_error(hPAM, "pam_vbox_read_prop: key \"%s\" contains no/wrong flags (%s)\n",
    467                            pszKey, pszFlags);
     456            pam_vbox_error(hPAM, "pam_vbox_read_prop: key \"%s\" contains no/wrong flags (%s)\n", pszKey, pszFlags);
    468457            rc = VERR_ACCESS_DENIED;
    469458        }
     
    474463            if (!RTStrPrintf(pszValue, cbValue, "%s", pszValTemp))
    475464            {
    476                 pam_vbox_error(hPAM, "pam_vbox_read_prop: could not store value of key \"%s\"\n",
    477                                pszKey);
     465                pam_vbox_error(hPAM, "pam_vbox_read_prop: could not store value of key \"%s\"\n", pszKey);
    478466                rc = VERR_INVALID_PARAMETER;
    479467            }
    480468
    481469            if (RT_SUCCESS(rc))
    482                 pam_vbox_log(hPAM, "pam_vbox_read_prop: read key \"%s\"=\"%s\"\n",
    483                              pszKey, pszValue);
    484         }
    485     }
    486 
     470                pam_vbox_log(hPAM, "pam_vbox_read_prop: read key \"%s\"=\"%s\"\n", pszKey, pszValue);
     471        }
     472    }
     473
     474    RTMemFree(pvBuf);
    487475    pam_vbox_log(hPAM, "pam_vbox_read_prop: read key \"%s\" with rc=%Rrc\n",
    488476                 pszKey, rc);
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette