[Pkg-wmaker-commits] [wmbiff] 08/17: fix bug reported by Jingshao Chen <jingshaochen at sbcglobal.net> with buffering trouble, and incorporate a regression test to keep it from accidentally popping up again
Doug Torrance
dtorrance-guest at moszumanska.debian.org
Thu Aug 20 03:04:20 UTC 2015
This is an automated email from the git hooks/post-receive script.
dtorrance-guest pushed a commit to tag wmbiff_0_4_18
in repository wmbiff.
commit 16c314bde66dbfc06eb9aeffdffaf1876f5e29ee
Author: bluehal <bluehal>
Date: Tue Oct 28 07:09:21 2003 +0000
fix bug reported by Jingshao Chen <jingshaochen at sbcglobal.net> with buffering trouble, and incorporate a regression test to keep it from accidentally popping up again
---
wmbiff/.cvsignore | 1 +
wmbiff/Makefile.am | 6 ++++--
wmbiff/test_tlscomm.c | 28 +++++++++++++++++++++-------
3 files changed, 26 insertions(+), 9 deletions(-)
diff --git a/wmbiff/.cvsignore b/wmbiff/.cvsignore
index b44633c..52f5c56 100644
--- a/wmbiff/.cvsignore
+++ b/wmbiff/.cvsignore
@@ -9,3 +9,4 @@ wmbiff-master-contrast.xpm
.deps
.elog
test_wmbiff
+test_tlscomm
diff --git a/wmbiff/Makefile.am b/wmbiff/Makefile.am
index 059ed36..8d48840 100644
--- a/wmbiff/Makefile.am
+++ b/wmbiff/Makefile.am
@@ -1,5 +1,5 @@
-TESTS = test_wmbiff
-noinst_PROGRAMS = test_wmbiff
+TESTS = test_wmbiff test_tlscomm
+noinst_PROGRAMS = test_wmbiff test_tlscomm
bin_PROGRAMS = wmbiff
wmbiff_SOURCES = wmbiff.c socket.c Pop3Client.c LicqClient.c mboxClient.c \
maildirClient.c Imap4Client.c tlsComm.c tlsComm.h ShellClient.c \
@@ -11,6 +11,8 @@ wmbiff_DEPENDENCIES = ../wmgeneral/libwmgeneral.a Makefile @GNUTLS_COMMON_O@
test_wmbiff_SOURCES = ShellClient.c charutil.c charutil.h Client.h \
test_wmbiff.c passwordMgr.c Imap4Client.c regulo.c Pop3Client.c \
tlsComm.c tlsComm.h socket.c
+test_tlscomm_SOURCES = test_tlscomm.c \
+ tlsComm.c tlsComm.h
EXTRA_test_wmbiff_SOURCES = gnutls-common.c gnutls-common.h
test_wmbiff_LDADD = @LIBGCRYPT_LIBS@
man_MANS = wmbiff.1 wmbiffrc.5
diff --git a/wmbiff/test_tlscomm.c b/wmbiff/test_tlscomm.c
index b3ea83a..197d4b6 100644
--- a/wmbiff/test_tlscomm.c
+++ b/wmbiff/test_tlscomm.c
@@ -1,18 +1,27 @@
#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
#include <sys/types.h>
#include <sys/time.h>
+#include <unistd.h>
int debug_default = 2;
+int SkipCertificateCheck = 0;
+const char *certificate_filename = NULL;
+int exists(const char *filename __attribute__((unused))) { return(0); }
+int print_info(void * state __attribute__((unused))) { return(0); }
+int Relax = 1;
+
int indices[12];
-char *sequence[][4] = {
+const char *sequence[][4] = {
{ NULL, NULL, NULL, NULL },
{ "prefix", " hello", NULL },
{ "pre", "fix", " hello", NULL },
};
/* trick tlscomm into believing it can read. */
-int read(int s, char *buf, int buflen) {
+int read(int s, void *buf, size_t buflen) {
int val = indices[s]++;
if(sequence[s][val] == NULL) {
@@ -25,9 +34,11 @@ int read(int s, char *buf, int buflen) {
}
}
-int select(int nfds, fd_set *r, fd_set *w, fd_set *x, struct timeval *tv) {
+int select(int nfds, fd_set *r, fd_set *w __attribute__((unused)),
+ fd_set *x __attribute__((unused)),
+ struct timeval *tv __attribute__((unused))) {
int i;
- int ready;
+ int ready = 0;
for(i=0;i<nfds;i++) {
if(FD_ISSET(i,r) && sequence[i][indices[i]] != NULL) {
ready++;
@@ -38,6 +49,7 @@ int select(int nfds, fd_set *r, fd_set *w, fd_set *x, struct timeval *tv) {
if(ready == 0) {
printf("botched.\n");
}
+ return ready;
}
#define BUF_SIZE 1024
@@ -51,17 +63,19 @@ struct connection_state {
void * pc; /* mailbox handle for debugging messages */
};
-int main(int argc, char **argv) {
+int main(int argc __attribute__((unused)),
+ char **argv __attribute__((unused))) {
char buf[255];
struct connection_state scs;
- scs.name = "test";
+ scs.name = strdup("test");
scs.unprocessed[0] = '\0';
scs.pc = NULL;
- // alarm(10);
+ alarm(10);
for(scs.sd = 1; scs.sd < 3; scs.sd++) {
memset(scs.unprocessed, 0, BUF_SIZE);
printf("%d\n", tlscomm_expect(&scs, "prefix", buf, 255));
}
+ return 0;
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-wmaker/wmbiff.git
More information about the Pkg-wmaker-commits
mailing list