diff --git a/src/3proxy.c b/src/3proxy.c index 9082f50..57963f0 100644 --- a/src/3proxy.c +++ b/src/3proxy.c @@ -199,6 +199,8 @@ void dumpcounters(struct trafcount *tlin, int counterd){ unsigned char tmpbuf[8192]; struct trafcount *tl; + ssize_t len; + if(counterd >= 0 && tlin) { conf.time = time(0); @@ -218,7 +220,8 @@ void dumpcounters(struct trafcount *tlin, int counterd){ cheader.updated = conf.time; lseek(counterd, 0, SEEK_SET); - write(counterd, &cheader, sizeof(struct counter_header)); + len = write(counterd, &cheader, sizeof(struct counter_header)); + if (len != sizeof(struct counter_header)) fprintf(stderr, "%s error: written %ld bytes\n", __func__, len); for(tl=tlin; tl; tl = tl->next){ if(tl->number){ lseek(counterd, @@ -227,7 +230,8 @@ void dumpcounters(struct trafcount *tlin, int counterd){ crecord.traf64 = tl->traf64; crecord.cleared = tl->cleared; crecord.updated = tl->updated; - write(counterd, &crecord, sizeof(struct counter_record)); + len = write(counterd, &crecord, sizeof(struct counter_record)); + if (len != sizeof(struct counter_header)) fprintf(stderr, "%s error: written %ld bytes\n", __func__, len); } if(tl->type!=NEVER && timechanged(tl->cleared, conf.time, tl->type)){ tl->cleared = conf.time; @@ -318,7 +322,7 @@ void cyclestep(void){ else strcat((char *)tmpbuf, (char *)conf.archiver[i]); } - system((char *)tmpbuf+1); + if (system((char *)tmpbuf+1)==-1) fprintf(stderr, "%s: some error in system() call\n", __func__); } } } diff --git a/src/conf.c b/src/conf.c index b29d835..b65b0a0 100644 --- a/src/conf.c +++ b/src/conf.c @@ -1274,6 +1274,7 @@ static int h_ace(int argc, unsigned char **argv){ if((acl->action == COUNTIN)||(acl->action == COUNTOUT)||(acl->action == COUNTALL)) { unsigned long lim; + ssize_t len; tl->comment = ( char *)argv[1]; while(isdigit(*tl->comment))tl->comment++; @@ -1295,7 +1296,8 @@ static int h_ace(int argc, unsigned char **argv){ sizeof(struct counter_header) + (tl->number - 1) * sizeof(struct counter_record), SEEK_SET); memset(&crecord, 0, sizeof(struct counter_record)); - read(conf.counterd, &crecord, sizeof(struct counter_record)); + len = read(conf.counterd, &crecord, sizeof(struct counter_record)); + if (lentraf64 = crecord.traf64; tl->cleared = crecord.cleared; tl->updated = crecord.updated; @@ -1522,7 +1524,10 @@ static int h_chroot(int argc, unsigned char **argv){ fprintf(stderr, "Unable to set uid %d", (int)uid); return(5); } - chdir("/"); + if (chdir("/")!=0) { + fprintf(stderr, "Unable to chdir /"); + return(6); + } return 0; } #endif diff --git a/src/plugins/StringsPlugin/StringsPlugin.c b/src/plugins/StringsPlugin/StringsPlugin.c index e97098d..4e7faa1 100644 --- a/src/plugins/StringsPlugin/StringsPlugin.c +++ b/src/plugins/StringsPlugin/StringsPlugin.c @@ -32,7 +32,7 @@ char **load_string(FILE *f,int max_count_str, int *countloadstr, /*find start service section*/ while(!feof(f)) { - fgets(tmpbuf1, 1023,f); + if (!fgets(tmpbuf1, 1023,f)) break; if ((strstr(tmpbuf1,start))!=NULL) { i++; break; } tmpbuf1[0]='\0'; } @@ -51,7 +51,7 @@ char **load_string(FILE *f,int max_count_str, int *countloadstr, i=0; while ( !feof(f) || i< max_count_str) { - fgets(tmpbuf1, 1023,f); + if (!fgets(tmpbuf1, 1023,f)) break; if ((strstr(tmpbuf1,stop))!=NULL) { break; } diff --git a/src/structures.h b/src/structures.h index 6d929ca..988e828 100644 --- a/src/structures.h +++ b/src/structures.h @@ -16,8 +16,12 @@ #include #include #ifndef PRINTF_INT64_MODIFIER +#if __WORDSIZE == 64 +#define PRINTF_INT64_MODIFIER "l" +#else #define PRINTF_INT64_MODIFIER "ll" #endif +#endif #ifdef __cplusplus extern "C" { #endif @@ -711,7 +715,7 @@ struct sockfuncs { int (*_getsockname)(SOCKET s, struct sockaddr * name, socklen_t * namelen); int (*_getsockopt)(SOCKET s, int level, int optname, void * optval, socklen_t * optlen); int (*_setsockopt)(int s, int level, int optname, const void *optval, socklen_t optlen); - int (*_poll)(struct pollfd *fds, unsigned int nfds, int timeout); + int (*_poll)(struct pollfd *fds, nfds_t, int timeout); size_t (*_send)(SOCKET s, const void *msg, size_t len, int flags); size_t (*_sendto)(SOCKET s, const void *msg, size_t len, int flags, const struct sockaddr *to, SASIZETYPE tolen); size_t (*_recv)(SOCKET s, void *buf, size_t len, int flags); diff --git a/src/webadmin.c b/src/webadmin.c index 0aefc38..7478eac 100644 --- a/src/webadmin.c +++ b/src/webadmin.c @@ -593,7 +593,7 @@ void * adminchild(struct clientparam* param) { if(writable && !error){ fflush(writable); #ifndef _WINCE - ftruncate(fileno(writable), ftell(writable)); + if (ftruncate(fileno(writable), ftell(writable))!=0) perror("Failed to truncate"); #endif } printstr(&pp, error? "

Config file is not writable

Make sure you have \"writable\" command in configuration file":