From 6ddce21c523d3f1b0b15ba3454adf15f359ea328 Mon Sep 17 00:00:00 2001 From: leitner Date: Thu, 7 May 2015 23:50:12 +0000 Subject: [PATCH] cleanup in error handling corner cases --- printasn1.c | 2 ++ scan_ldapmodifyrequest.c | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/printasn1.c b/printasn1.c index 4bcf214..f430906 100644 --- a/printasn1.c +++ b/printasn1.c @@ -1,5 +1,7 @@ /* needs stdio.h and asn1.h included */ +#include + void printasn1(const char* buf,const char* max) { const char* maxstack[100]; size_t sptr=0; diff --git a/scan_ldapmodifyrequest.c b/scan_ldapmodifyrequest.c index ba42e4f..69d2e08 100644 --- a/scan_ldapmodifyrequest.c +++ b/scan_ldapmodifyrequest.c @@ -1,4 +1,5 @@ #include +#include #include "ldap.h" #if 0 @@ -19,7 +20,7 @@ size_t scan_ldapmodifyrequest(const char* src,const char* max,struct ModifyRequest* m) { size_t res,tmp,oslen; /* outer sequence length */ struct Modification* last=0; - m->m.next=0; + byte_zero(m,sizeof(*m)); if (!(res=scan_ldapstring(src,max,&m->object))) goto error; if (!(tmp=scan_asn1SEQUENCE(src+res,max,&oslen))) goto error; res+=tmp; @@ -31,6 +32,7 @@ size_t scan_ldapmodifyrequest(const char* src,const char* max,struct ModifyReque if (last) { struct Modification* cur; if (!(cur=malloc(sizeof(struct Modification)))) goto error; + byte_zero(cur,sizeof(*cur)); last->next=cur; last=cur; } else last=&m->m; @@ -59,8 +61,8 @@ size_t scan_ldapmodifyrequest(const char* src,const char* max,struct ModifyReque ilast=&last->vals; while (src+resa))) goto error; - (*ilast)->next=0; ilast=&(*ilast)->next; res+=tmp; }