summaryrefslogtreecommitdiffstats
path: root/daemons
diff options
context:
space:
mode:
authorJan Cholasta <jcholast@redhat.com>2014-11-05 08:50:26 +0000
committerMartin Kosek <mkosek@redhat.com>2014-11-05 15:28:27 +0100
commit9062dcada48d378f7c46759607aff03c17b11163 (patch)
tree83a38cd73e0157ce798085f5db151babf8e7ca52 /daemons
parent701dde3cb3b36173cbe00be5357bcdcbc6dd2b42 (diff)
downloadfreeipa-9062dcada48d378f7c46759607aff03c17b11163.tar.gz
freeipa-9062dcada48d378f7c46759607aff03c17b11163.tar.xz
freeipa-9062dcada48d378f7c46759607aff03c17b11163.zip
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>
Diffstat (limited to 'daemons')
-rw-r--r--daemons/ipa-slapi-plugins/ipa-otp-counter/berval.c2
-rw-r--r--daemons/ipa-slapi-plugins/ipa-otp-counter/ipa_otp_counter.c14
-rw-r--r--daemons/ipa-slapi-plugins/ipa-otp-lasttoken/ipa_otp_lasttoken.c6
3 files changed, 17 insertions, 5 deletions
diff --git a/daemons/ipa-slapi-plugins/ipa-otp-counter/berval.c b/daemons/ipa-slapi-plugins/ipa-otp-counter/berval.c
index 884e1a210..a2fe592f0 100644
--- a/daemons/ipa-slapi-plugins/ipa-otp-counter/berval.c
+++ b/daemons/ipa-slapi-plugins/ipa-otp-counter/berval.c
@@ -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);
diff --git a/daemons/ipa-slapi-plugins/ipa-otp-counter/ipa_otp_counter.c b/daemons/ipa-slapi-plugins/ipa-otp-counter/ipa_otp_counter.c
index 24ef9e240..da047d7dc 100644
--- a/daemons/ipa-slapi-plugins/ipa-otp-counter/ipa_otp_counter.c
+++ b/daemons/ipa-slapi-plugins/ipa-otp-counter/ipa_otp_counter.c
@@ -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;
diff --git a/daemons/ipa-slapi-plugins/ipa-otp-lasttoken/ipa_otp_lasttoken.c b/daemons/ipa-slapi-plugins/ipa-otp-lasttoken/ipa_otp_lasttoken.c
index 94d24ae0f..d20fca1e7 100644
--- a/daemons/ipa-slapi-plugins/ipa-otp-lasttoken/ipa_otp_lasttoken.c
+++ b/daemons/ipa-slapi-plugins/ipa-otp-lasttoken/ipa_otp_lasttoken.c
@@ -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;
}