From: Rick W. <rw...@us...> - 2007-10-01 06:59:53
|
Update of /cvsroot/vpopmail/vpopmail In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv29592 Modified Files: ChangeLog config.h.in maildirquota.c vchkpw.c Log Message: another attempt at signedness warnings Index: vchkpw.c =================================================================== RCS file: /cvsroot/vpopmail/vpopmail/vchkpw.c,v retrieving revision 1.19 retrieving revision 1.20 diff -u -d -r1.19 -r1.20 --- vchkpw.c 22 May 2007 03:59:00 -0000 1.19 +++ vchkpw.c 1 Oct 2007 06:59:55 -0000 1.20 @@ -92,8 +92,8 @@ void vlog(int verror, char *TheUser, char *TheDomain, char *ThePass, char *TheName, char *IpAddr, char *LogLine); void vchkpw_exit(int err); void run_command(char *prog); -int authcram(unsigned char *response, unsigned char *challenge, unsigned char *password); -int authapop(unsigned char *password, unsigned char *timestamp, unsigned char *clearpass); +int authcram( char *response, char *challenge, char *password); +int authapop( char *password, char *timestamp, char *clearpass); #define POP_CONN 0 #define SMTP_CONN 1 @@ -737,14 +737,25 @@ #endif } -int authcram(unsigned char *response, unsigned char *challenge, unsigned char *password) +int authcram( char *response, char *challenge, char *password) { + unsigned char *uchallenge; + unsigned char *upassword; unsigned char digest[16]; - unsigned char digascii[33]; + char digascii[33]; unsigned char h; int j; - hmac_md5( challenge, strlen(challenge), password, strlen(password), digest); + uchallenge = malloc( strlen(challenge)+1); + memcpy( uchallenge, challenge, strlen( challenge )); + + upassword = malloc( strlen(password)+1); + memcpy( upassword, password, strlen(password)+1); + + hmac_md5( uchallenge, strlen(challenge), upassword, strlen(password), digest); + + free( uchallenge ); + free( upassword ); digascii[32]=0; @@ -759,18 +770,31 @@ return(strcmp(digascii,response)); } -int authapop(unsigned char *password, unsigned char *timestamp, unsigned char *clearpass) +int authapop( char *password, char *timestamp, char *clearpass) { MD5_CTX context; unsigned char digest[16]; char encrypted[16*2+1]; char *s; int i; - + + unsigned char *utimestamp; + unsigned char *uclearpass; + + utimestamp = malloc( strlen( timestamp )); + memcpy( utimestamp, timestamp, strlen( timestamp )); + + uclearpass = malloc( strlen( clearpass )); + memcpy( uclearpass, clearpass, strlen( clearpass )); + MD5Init(&context); - MD5Update(&context, timestamp, strlen(timestamp)); - MD5Update(&context, clearpass, strlen(clearpass)); + MD5Update(&context, utimestamp, strlen(timestamp)); + MD5Update(&context, uclearpass, strlen(clearpass)); MD5Final(digest, &context); + + free( utimestamp ); + free( uclearpass ); + s = encrypted; for (i = 0; i < (int)sizeof(digest); ++i) { *s = hextab[digest[i]/16]; ++s; Index: config.h.in =================================================================== RCS file: /cvsroot/vpopmail/vpopmail/config.h.in,v retrieving revision 1.15 retrieving revision 1.16 diff -u -d -r1.15 -r1.16 --- config.h.in 22 May 2007 03:58:58 -0000 1.15 +++ config.h.in 1 Oct 2007 06:59:55 -0000 1.16 @@ -354,13 +354,13 @@ /* Define to `int' if <sys/types.h> does not define. */ #undef mode_t -/* Define to `long' if <sys/types.h> does not define. */ +/* Define to `long int' if <sys/types.h> does not define. */ #undef off_t /* Define to `int' if <sys/types.h> does not define. */ #undef pid_t -/* Define to `unsigned' if <sys/types.h> does not define. */ +/* Define to `unsigned int' if <sys/types.h> does not define. */ #undef size_t /* Define to `int' if <sys/types.h> doesn't define. */ Index: maildirquota.c =================================================================== RCS file: /cvsroot/vpopmail/vpopmail/maildirquota.c,v retrieving revision 1.16 retrieving revision 1.17 diff -u -d -r1.16 -r1.17 --- maildirquota.c 29 Sep 2007 22:02:46 -0000 1.16 +++ maildirquota.c 1 Oct 2007 06:59:55 -0000 1.17 @@ -1,6 +1,6 @@ /* * $Id$ - * Copyright (C) 1999-2003 Inter7 Internet Technologies, Inc. + * Copyright (C) 1999-2004 Inter7 Internet Technologies, Inc. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -37,22 +37,23 @@ #include "config.h" /* private functions - no name clashes with courier */ -static char *makenewmaildirsizename(const char *sizep, int *cntp ); -static int countcurnew(const char *dir, time_t *, off_t *sizep, unsigned *cntp ); -static int countsubdir(const char *dir, const char *, - time_t *, off_t *, unsigned *); +static char *makenewmaildirsizename(const char *, int *); +static int countcurnew(const char *, time_t *, off_t *, int *); +static int countsubdir(const char *, const char *, + time_t *, off_t *, int *); static int statcurnew(const char *, time_t *); static int statsubdir(const char *, const char *, time_t *); static int doaddquota(const char *, int, const char *, long, int, int); static int docheckquota(const char *dir, int *maildirsize_fdptr, const char *quota_type, long xtra_size, int xtra_cnt, int *percentage); -static int docount(const char *, time_t *, off_t *, unsigned *); +static int docount(const char *, time_t *, off_t *, int *); static int maildir_checkquota(const char *dir, int *maildirsize_fdptr, const char *quota_type, long xtra_size, int xtra_cnt); -/* moved into maildirquota.h as non-static +/* static int maildir_addquota(const char *dir, int maildirsize_fd, const char *quota_type, long maildirsize_size, int maildirsize_cnt); */ + static int maildir_safeopen(const char *path, int mode, int perm); static char *str_pid_t(pid_t t, char *arg); static char *str_time_t(time_t t, char *arg); @@ -73,7 +74,7 @@ char domdir[MAX_PW_DIR]; char *p; char domain[256]; -long size = 0; +long size = 0; unsigned long maxsize = 0; int cnt = 0; int maxcnt = 0; @@ -98,9 +99,6 @@ maxsize = limits.diskquota * 1024 * 1024; maxcnt = limits.maxmsgcount; - /* only check the quota if one is set. */ - if ((maxsize == 0) && (maxcnt == 0)) return 0; - if (vget_assign (domain, domdir, sizeof(domdir), NULL, NULL) == NULL) return -1; @@ -171,7 +169,7 @@ return 0; } -int wrapreaduserquota(const char* dir, long *sizep, unsigned int *cntp) +int wrapreaduserquota(const char* dir, off_t *sizep, int *cntp) { time_t tm; time_t maxtime; @@ -248,38 +246,64 @@ { int retval; off_t s; - unsigned c; - s = ( off_t ) *sizep; - c = *cntp; - retval = wrapreaduserquota(dir, &s, &c); + + s = (off_t) *sizep; + retval = wrapreaduserquota(dir, &s, cntp); *sizep = (long) s; - *cntp = (int) c; return retval; } int user_over_maildirquota( const char *dir, const char *q) { struct stat stat_buf; -int quotafd = -1; -int ret_value = 0; +int quotafd; +int ret_value; if (fstat(0, &stat_buf) == 0 && S_ISREG(stat_buf.st_mode) && stat_buf.st_size > 0 && *q) { - ret_value = (maildir_checkquota(dir, "afd, q, stat_buf.st_size, 1) - && errno != EAGAIN); + if (maildir_checkquota(dir, "afd, q, stat_buf.st_size, 1) + && errno != EAGAIN) + { + if (quotafd >= 0) close(quotafd); + ret_value = 1; + } else { + maildir_addquota(dir, quotafd, q, stat_buf.st_size, 1); + if (quotafd >= 0) close(quotafd); + ret_value = 0; + } + } else { + ret_value = 0; } - if (quotafd != -1) close(quotafd); return(ret_value); } +void add_warningsize_to_quota( const char *dir, const char *q) +{ +struct stat stat_buf; +int quotafd; +char quotawarnmsg[500]; + + snprintf(quotawarnmsg, sizeof(quotawarnmsg), "%s/%s/.quotawarn.msg", VPOPMAILDIR, DOMAINS_DIR); + + if (stat(quotawarnmsg, &stat_buf) == 0 && S_ISREG(stat_buf.st_mode) && + stat_buf.st_size > 0 && *q) + { + maildir_checkquota(dir, "afd, q, stat_buf.st_size, 1); + if (quotafd >= 0) close(quotafd); + maildir_addquota(dir, quotafd, q, + stat_buf.st_size, 1); + if (quotafd >= 0) close(quotafd); + } +} + /* Read the maildirsize file */ static int maildirsize_read(const char *filename, /* The filename */ int *fdptr, /* Keep the file descriptor open */ off_t *sizeptr, /* Grand total of maildir size */ - unsigned *cntptr, /* Grand total of message count */ + int *cntptr, /* Grand total of message count */ unsigned *nlines, /* # of lines in maildirsize */ struct stat *statptr) /* The stats on maildirsize */ { @@ -439,9 +463,9 @@ char *checkfolder=(char *)malloc(strlen(dir)+sizeof("/maildirfolder")); char *newmaildirsizename; struct stat stat_buf; -int maildirsize_fd = -1; +int maildirsize_fd; off_t maildirsize_size; -unsigned maildirsize_cnt; +int maildirsize_cnt; unsigned maildirsize_nlines; int n; time_t tm; @@ -483,8 +507,6 @@ return (n); } - /* rebuild the maildirsize file */ - maxtime=0; maildirsize_size=0; maildirsize_cnt=0; @@ -531,10 +553,10 @@ if (doaddquota(dir, maildirsize_fd, quota_type, maildirsize_size, maildirsize_cnt, 1)) { + free(newmaildirsizename); unlink(newmaildirsizename); close(maildirsize_fd); *maildirsize_fdptr= -1; - free(newmaildirsizename); free(checkfolder); return (-1); } @@ -543,6 +565,7 @@ if (rename(newmaildirsizename, checkfolder)) { + free(checkfolder); unlink(newmaildirsizename); close(maildirsize_fd); *maildirsize_fdptr= -1; @@ -789,7 +812,8 @@ return (n); } -static int countcurnew(const char *dir, time_t *maxtime, off_t *sizep, unsigned int *cntp) +static int countcurnew(const char *dir, time_t *maxtime, + off_t *sizep, int *cntp) { char *p=(char *)malloc(strlen(dir)+5); int n; @@ -807,7 +831,7 @@ } static int countsubdir(const char *dir, const char *subdir, time_t *maxtime, - off_t *sizep, unsigned *cntp) + off_t *sizep, int *cntp) { char *p; int n; @@ -825,8 +849,7 @@ } static int docount(const char *dir, time_t *dirstamp, - off_t *sizep, unsigned *cntp) - + off_t *sizep, int *cntp) { struct stat stat_buf; char *p; Index: ChangeLog =================================================================== RCS file: /cvsroot/vpopmail/vpopmail/ChangeLog,v retrieving revision 1.176 retrieving revision 1.177 diff -u -d -r1.176 -r1.177 --- ChangeLog 30 Sep 2007 02:11:14 -0000 1.176 +++ ChangeLog 1 Oct 2007 06:59:55 -0000 1.177 @@ -2,6 +2,8 @@ or info related to the entry. <http://sourceforge.net/projects/vpopmail/> 5.4.25 - unreleased + Rick Widmer + - another try at signedness warnings in maildirquota and vchkpw 5.4.24 - Released 29-Sep-2007 |