Projects / ldapdiff / Comments

Comments for ldapdiff

05 Jul 2011 22:47 confusedhacker

Comparing this program to patch is only useful if your idea of patching involves replacing entire tires to add a scratch. This tool deletes and then recreates the entries, instead of doing a smarter delta-level "true diff" that would involve the actual attributes and their values.

09 May 2007 13:12 tr1449

Re: Bug that prevents streaming operations
Thanks Enzo,


your patch has been applied to "ldapdiff-1.2.3" available at http://webtomware.rhoen.de.


regards


Thomas


16 Mar 2007 04:40 enzom

Bug that prevents streaming operations
If the "-f" option is not given, ldapdiff reads the LDIF data from stdin.
Unfortunately, in ldapread.c there is code calling ftell() and fseek(), which
fails (without warnings) if stdin is not seekable (e.g., it's a pipe). I
reported the bug to the author two weeks ago, but I haven't heard from him, so
here is the code for the fix, which replaces ftell()/fseek() with the pipe-friendly getc()/ungetc():


 
[...]#if 0 /* old code if'd out */   filepos =
ftell(f);   while(fgets(folderline,sizeof(folderline),f) !=
NULL){    /* strip \n */    if((pstrip =
strchr(folderline,'\n')) != NULL){     *pstrip =
'\0';    }    /* strip \r\n
*/    if((pstrip = strstr(folderline,"\r\n")) !=
NULL){     *pstrip = '\0';   
}    if(folderline[0] == ' ' || folderline[0] ==
'\t'){     clines++;    
if(strlen(line) + strlen(folderline+1) >
MAXATTRLEN){     
ldiflog(LOG0,       "attribute size to big
file:%s line:%d",__FILE__,__LINE__);     
exit(EXITLDERROR);     }    
pline = realloc(pline,strlen(pline)+1 +
strlen(folderline));    
strcat(pline,folderline+1);     filepos =
ftell(f);    }else{    
break;    }   }  
fseek(f,filepos,SEEK_SET);#else    /* new code
*/   for(;;) {    char nextch =
getc(f);    ungetc(nextch, f);   
if(nextch != ' ' && nextch != '\t')    
break;    if(fgets(folderline,sizeof(folderline),f) ==
NULL)     break;    if((pstrip =
strchr(folderline,'\n')) != NULL){     *pstrip =
'\0';    }    /* strip \r\n
*/    if((pstrip = strstr(folderline,"\r\n")) !=
NULL){     *pstrip = '\0';   
}    clines++;    if(strlen(line) +
strlen(folderline+1) > MAXATTRLEN){    
ldiflog(LOG0,      "attribute size too big file:%s
line:%d",__FILE__,__LINE__);    
exit(EXITLDERROR);    }    pline =
realloc(pline,strlen(pline)+1 + strlen(folderline));   
strcat(pline,folderline+1);  
}#endif[...]

Screenshot

Project Spotlight

ReciJournal

An open, cross-platform journaling program.

Screenshot

Project Spotlight

Veusz

A scientific plotting package.