Changeset 208

Show
Ignore:
Timestamp:
05/12/04 00:46:53 (5 years ago)
Author:
svn
Message:

Added the optional use of snprintf for systems without it.
Unindented some preprocessor directives for picky compilers.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • op/trunk/main.c

    r207 r208  
    360360        if ((pw = getpwuid(getuid())) == NULL) return -1; 
    361361 
    362        #ifdef SECURID 
     362#ifdef SECURID 
    363363        if ((cp=FindOpt(cmd, "securid")) != NULL) { 
    364364                memset(&sd_dat, 0, sizeof(sd_dat));   /* clear sd_auth struct */ 
     
    370370                if (sd_auth(sd)) return -1; 
    371371        } 
    372        #else 
     372#else 
    373373        if ((cp=FindOpt(cmd, "securid")) != NULL) { 
    374374                return logger(LOG_ERR | LOG_PRINT, "SecureID not supported by op. Access denied"); 
    375375        } 
    376        #endif  
     376#endif         
    377377 
    378378        if ((cp=FindOpt(cmd, "password")) != NULL) { 
     
    405405                                return logger(LOG_ERR, "Incorrect direct password"); 
    406406                } else { 
    407                        #ifdef USE_SHADOW 
     407#ifdef USE_SHADOW 
    408408                        if (strcmp(pw->pw_passwd,"x")==0){ /* Shadow passwords */ 
    409409                                if ((spw = getspnam(pw->pw_name)) == NULL) 
     
    411411                                pw->pw_passwd=spw->sp_pwdp; 
    412412                        } 
    413                        #endif 
     413#endif 
    414414 
    415415                        if (!cp && strcmp(crypt(np, pw->pw_passwd), pw->pw_passwd) != 0) 
     
    10341034} 
    10351035 
     1036#ifndef HAVE_SNPRINTF 
     1037#warning You have not compiled op with snprintf support, presumably because 
     1038#warning your system does not have it. This leaves op potentially open to 
     1039#warning buffer overflows. 
     1040#endif 
     1041 
    10361042int vlogger(unsigned level, const char *format, va_list args) { 
    10371043char buffer[MAXSTRLEN], buffer2[MAXSTRLEN], buffer3[MAXSTRLEN]; 
     
    10401046        if (realuser) username = realuser->pw_name; 
    10411047 
     1048#ifdef HAVE_SNPRINTF 
    10421049        vsnprintf(buffer2, MAXSTRLEN, format, args); 
     1050#else 
     1051        vsprintf(buffer2, format, args); 
     1052#endif 
    10431053        if (level & LOG_PRINT) printf("%s\n", buffer2); 
    10441054        level &= ~LOG_PRINT; 
     1055#ifdef HAVE_SNPRINTF 
    10451056        snprintf(buffer, MAXSTRLEN, "%s =>%s: %s", username,  
    10461057                format_cmd(gargc, gargv, buffer3, MAXSTRLEN), 
    10471058                buffer2); 
     1059#else 
     1060        sprintf(buffer, "%s =>%s: %s", username,  
     1061                format_cmd(gargc, gargv, buffer3, MAXSTRLEN), 
     1062                buffer2); 
     1063#endif 
    10481064        syslog(level, "%s", buffer); 
    10491065        return -1; 
     
    10641080 
    10651081        va_start(ap, format); 
     1082#ifdef HAVE_SNPRINTF 
    10661083        vsnprintf(buffer, MAXSTRLEN, format, ap); 
     1084#else 
     1085        vsprintf(buffer, format, ap); 
     1086#endif 
    10671087        fprintf(stderr, "%s\n", buffer); 
    10681088        if (logit) logger(LOG_ERR, "%s", buffer); 
  • op/trunk/Makefile

    r207 r208  
    2323# 
    2424#OPTS= -DUSE_SHADOW -g 
    25 OPTS= -DXAUTH=\"/usr/X11R6/bin/xauth\" -DUSE_PAM -
     25OPTS= -DXAUTH=\"/usr/X11R6/bin/xauth\" -DUSE_PAM -DHAVE_SNPRINTF -
    2626LDFLAGS = -g 
    2727#