mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2025-02-25 18:55:28 -06:00
Fix various bugs in ipa-opt-counter and ipa-otp-lasttoken
Fixes a wrong sizeof argument and unchecked return values. https://fedorahosted.org/freeipa/ticket/4651 Reviewed-By: Alexander Bokovoy <abokovoy@redhat.com>
This commit is contained in:
committed by
Martin Kosek
parent
701dde3cb3
commit
9062dcada4
@@ -48,7 +48,7 @@ berval_new_longlong(long long value)
|
||||
{
|
||||
struct berval *bv;
|
||||
|
||||
bv = (struct berval*) slapi_ch_malloc(sizeof(struct berval*));
|
||||
bv = (struct berval*) slapi_ch_malloc(sizeof(struct berval));
|
||||
bv->bv_val = slapi_ch_smprintf("%lld", value);
|
||||
bv->bv_len = strlen(bv->bv_val);
|
||||
|
||||
|
||||
@@ -50,6 +50,7 @@
|
||||
|
||||
#include "berval.h"
|
||||
#include "ldapmod.h"
|
||||
#include "util.h"
|
||||
|
||||
#include <limits.h>
|
||||
|
||||
@@ -140,6 +141,7 @@ normalize_input(LDAPMod ***mods, const char *attr, long long ctr)
|
||||
case LDAP_MOD_REPLACE:
|
||||
case LDAP_MOD_INCREMENT:
|
||||
e++;
|
||||
/* fall through */
|
||||
default:
|
||||
c++;
|
||||
}
|
||||
@@ -284,8 +286,12 @@ preop_mod(Slapi_PBlock *pb)
|
||||
cpre = get_counter(epre, attr);
|
||||
|
||||
if (repl == 0) {
|
||||
if (normalize_input(&mods, attr, cpre) != 0)
|
||||
slapi_pblock_set(pb, SLAPI_MODIFY_MODS, mods);
|
||||
if (normalize_input(&mods, attr, cpre) != 0) {
|
||||
if (slapi_pblock_set(pb, SLAPI_MODIFY_MODS, mods)) {
|
||||
LOG_FATAL("slapi_pblock_set failed!\n");
|
||||
goto error;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!simulate(mods, attr, cpre, &cpost) && repl == 0) {
|
||||
@@ -316,7 +322,9 @@ preop_mod(Slapi_PBlock *pb)
|
||||
error:
|
||||
rc = LDAP_UNWILLING_TO_PERFORM;
|
||||
slapi_send_ldap_result(pb, rc, NULL, msg, 0, NULL);
|
||||
slapi_pblock_set(pb, SLAPI_RESULT_CODE, &rc);
|
||||
if (slapi_pblock_set(pb, SLAPI_RESULT_CODE, &rc)) {
|
||||
LOG_FATAL("slapi_pblock_set failed!\n");
|
||||
}
|
||||
|
||||
slapi_ch_free_string(&msg);
|
||||
return rc;
|
||||
|
||||
@@ -44,6 +44,8 @@
|
||||
#include <libotp.h>
|
||||
#include <time.h>
|
||||
|
||||
#include "util.h"
|
||||
|
||||
#define PLUGIN_NAME "ipa-otp-lasttoken"
|
||||
#define LOG(sev, ...) \
|
||||
slapi_log_error(SLAPI_LOG_ ## sev, PLUGIN_NAME, \
|
||||
@@ -100,7 +102,9 @@ static inline int
|
||||
send_error(Slapi_PBlock *pb, int rc, char *errstr)
|
||||
{
|
||||
slapi_send_ldap_result(pb, rc, NULL, errstr, 0, NULL);
|
||||
slapi_pblock_set(pb, SLAPI_RESULT_CODE, &rc);
|
||||
if (slapi_pblock_set(pb, SLAPI_RESULT_CODE, &rc)) {
|
||||
LOG_FATAL("slapi_pblock_set failed!\n");
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user