[Pkg-wmaker-commits] [wmbiff] 52/84: valgrind debugging, and support for -exit. some bugs were probably fixed, but since nobody has noticed yet, I don't know if they mattered
Doug Torrance
dtorrance-guest at moszumanska.debian.org
Thu Aug 20 03:01:57 UTC 2015
This is an automated email from the git hooks/post-receive script.
dtorrance-guest pushed a commit to tag wmbiff_0_4_10
in repository wmbiff.
commit 09bd7e99e5360e42bef303061ccef870ec641de1
Author: bluehal <bluehal>
Date: Thu Jul 4 01:07:28 2002 +0000
valgrind debugging, and support for -exit. some bugs were probably fixed, but since nobody has noticed yet, I don't know if they mattered
---
wmbiff/Imap4Client.c | 3 +++
wmbiff/Makefile.am | 5 +++++
wmbiff/Pop3Client.c | 7 ++++---
wmbiff/charutil.c | 3 ++-
wmbiff/tlsComm.c | 30 +++++++++++++++++-------------
wmbiff/wmbiff.c | 19 +++++++++++++++----
6 files changed, 46 insertions(+), 21 deletions(-)
diff --git a/wmbiff/Imap4Client.c b/wmbiff/Imap4Client.c
index 0398b2e..f374735 100644
--- a/wmbiff/Imap4Client.c
+++ b/wmbiff/Imap4Client.c
@@ -363,6 +363,9 @@ int imap4Create( /*@notnull@ */ Pop3 pc, const char *const str)
grab_authList(str + regs.end[0], PCU.authList);
+ free(regs.end); // added 3 jul 02, appeasing valgrind
+ free(regs.start); // added 3 jul 02, appeasing valgrind
+
IMAP_DM(pc, DEBUG_INFO, "userName= '%s'\n", PCU.userName);
IMAP_DM(pc, DEBUG_INFO, "password is %d characters long\n",
(int) strlen(PCU.password));
diff --git a/wmbiff/Makefile.am b/wmbiff/Makefile.am
index 87da0a8..bb15a9b 100644
--- a/wmbiff/Makefile.am
+++ b/wmbiff/Makefile.am
@@ -53,3 +53,8 @@ config-h-check:
ls *.c | sort > cfiles
grep -l config.h *.c | sort | diff - cfiles
rm cfiles
+
+# just a reminder of how to run valgrind to get decent output.
+valgrind:
+ valgrind --leak-check=yes ./wmbiff -exit
+
diff --git a/wmbiff/Pop3Client.c b/wmbiff/Pop3Client.c
index 7b95f02..79793ec 100644
--- a/wmbiff/Pop3Client.c
+++ b/wmbiff/Pop3Client.c
@@ -1,4 +1,4 @@
-/* $Id: Pop3Client.c,v 1.14 2002/06/21 04:31:58 bluehal Exp $ */
+/* $Id: Pop3Client.c,v 1.15 2002/07/04 01:07:28 bluehal Exp $ */
/* Author : Scott Holden ( scotth at thezone.net )
Modified : Yong-iL Joh ( tolkien at mizi.com )
Modified : Jorge Garc�a ( Jorge.Garcia at uv.es )
@@ -198,9 +198,10 @@ int pop3Create(Pop3 pc, const char *str)
grab_authList(str + regs.end[0], PCU.authList);
+ free(regs.end); // added 3 jul 02, appeasing valgrind
+ free(regs.start); // added 3 jul 02, appeasing valgrind
+
POP_DM(pc, DEBUG_INFO, "userName= '%s'\n", PCU.userName);
- POP_DM(pc, DEBUG_INFO, "password= is %d characters long\n",
- strlen(PCU.password));
POP_DM(pc, DEBUG_INFO, "password is %d chars long\n",
strlen(PCU.password));
POP_DM(pc, DEBUG_INFO, "serverName= '%s'\n", PCU.serverName);
diff --git a/wmbiff/charutil.c b/wmbiff/charutil.c
index e3300de..cdb22d4 100644
--- a/wmbiff/charutil.c
+++ b/wmbiff/charutil.c
@@ -1,4 +1,4 @@
-/* $Id: charutil.c,v 1.12 2002/06/21 04:31:31 bluehal Exp $ */
+/* $Id: charutil.c,v 1.13 2002/07/04 01:07:28 bluehal Exp $ */
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
@@ -221,6 +221,7 @@ int compile_and_match_regex(const char *regex, const char *str, /*@out@ */
}
#endif
+ regfree(&rpbuf); // added 3 jul 02, appeasing valgrind
return matchedchars;
}
diff --git a/wmbiff/tlsComm.c b/wmbiff/tlsComm.c
index 15da9c9..9933275 100644
--- a/wmbiff/tlsComm.c
+++ b/wmbiff/tlsComm.c
@@ -124,6 +124,8 @@ getline_from_buffer(char *readbuffer, char *linebuffer, int linebuflen)
if (i != 0) {
/* grab the end of line too! */
i++;
+ /* advance past the newline */
+ p++;
/* copy a line into the linebuffer */
strncpy(linebuffer, readbuffer, (size_t) i);
/* sigh, null terminate */
@@ -132,10 +134,9 @@ getline_from_buffer(char *readbuffer, char *linebuffer, int linebuflen)
instead with strcpy... I think. */
q = readbuffer;
if (*p != '\0') {
- p++;
- do {
+ while (*p != '\0') {
*(q++) = *(p++);
- } while (*p != '\0');
+ }
}
/* null terminate */
*(q++) = *(p++);
@@ -154,17 +155,18 @@ getline_from_buffer(char *readbuffer, char *linebuffer, int linebuflen)
certainly tlscomm_close(scs): don't _expect() anything
unless anything else would represent failure */
int tlscomm_expect(struct connection_state *scs,
- const char *prefix, char *buf, int buflen)
+ const char *prefix, char *linebuf, int buflen)
{
int prefixlen = (int) strlen(prefix);
int readbytes = -1;
- memset(buf, 0, buflen);
+ memset(linebuf, 0, buflen);
TDM(DEBUG_INFO, "%s: expecting: %s\n", scs->name, prefix);
while (wait_for_it(scs->sd, EXPECT_TIMEOUT)) {
#ifdef HAVE_GNUTLS_H
if (scs->state) {
+ /* BUF_SIZE - 1 leaves room for trailing \0 */
readbytes =
- gnutls_read(scs->state, scs->unprocessed, BUF_SIZE);
+ gnutls_read(scs->state, scs->unprocessed, BUF_SIZE - 1);
if (readbytes < 0) {
handle_gnutls_read_error(readbytes, scs);
return 0;
@@ -176,35 +178,37 @@ int tlscomm_expect(struct connection_state *scs,
} else
#endif
{
- readbytes = read(scs->sd, scs->unprocessed, BUF_SIZE);
+ readbytes = read(scs->sd, scs->unprocessed, BUF_SIZE - 1);
if (readbytes < 0) {
TDM(DEBUG_ERROR, "%s: error reading: %s\n", scs->name,
strerror(errno));
return 0;
}
- if (readbytes > BUF_SIZE) {
+ if (readbytes >= BUF_SIZE) {
TDM(DEBUG_ERROR, "%s: unexpected read bork!: %d %s\n",
scs->name, readbytes, strerror(errno));
}
}
+ /* force null termination */
+ scs->unprocessed[readbytes] = '\0';
if (readbytes == 0) {
return 0; /* bummer */
} else
while (readbytes >= prefixlen) {
int linebytes;
linebytes =
- getline_from_buffer(scs->unprocessed, buf, buflen);
+ getline_from_buffer(scs->unprocessed, linebuf, buflen);
if (linebytes == 0) {
readbytes = 0;
} else {
readbytes -= linebytes;
- if (strncmp(buf, prefix, prefixlen) == 0) {
+ if (strncmp(linebuf, prefix, prefixlen) == 0) {
TDM(DEBUG_INFO, "%s: got: %*s", scs->name,
- readbytes, buf);
+ readbytes, linebuf);
return 1; /* got it! */
}
TDM(DEBUG_INFO, "%s: dumped(%d/%d): %.*s", scs->name,
- linebytes, readbytes, linebytes, buf);
+ linebytes, readbytes, linebytes, linebuf);
}
}
}
@@ -213,7 +217,7 @@ int tlscomm_expect(struct connection_state *scs,
scs->name, prefix);
} else {
TDM(DEBUG_ERROR, "%s: expecting: '%s', saw (%d): %s\n",
- scs->name, prefix, readbytes, buf);
+ scs->name, prefix, readbytes, linebuf);
}
return 0; /* wait_for_it failed */
}
diff --git a/wmbiff/wmbiff.c b/wmbiff/wmbiff.c
index 4c681ed..92c8a1c 100644
--- a/wmbiff/wmbiff.c
+++ b/wmbiff/wmbiff.c
@@ -1,4 +1,4 @@
-/* $Id: wmbiff.c,v 1.31 2002/06/23 01:26:56 bluehal Exp $ */
+/* $Id: wmbiff.c,v 1.32 2002/07/04 01:07:28 bluehal Exp $ */
#ifdef HAVE_CONFIG_H
#include <config.h>
@@ -73,7 +73,7 @@ void displayMsgCounters(int, int, int *, int *);
void usage(void);
void printversion(void);
-void do_biff(int argc, char **argv) __attribute__ ((noreturn));
+void do_biff(int argc, char **argv);
void parse_mbox_path(int item);
static void BlitString(const char *name, int x, int y, int new);
void BlitNum(int num, int x, int y, int new);
@@ -90,6 +90,7 @@ const char *highlight = "yellow";
const int num_mailboxes = 5;
const int x_origin = 5;
const int y_origin = 5;
+int forever = 1;
/* where vertically the mailbox sits for blitting characters. */
static int mbox_y(int mboxnum)
@@ -344,7 +345,7 @@ static int periodic_mail_check(void)
void do_biff(int argc, char **argv)
-{ /*@noreturn@ */
+{
int i;
int but_pressed_region = -1;
time_t curtime;
@@ -388,7 +389,9 @@ void do_biff(int argc, char **argv)
}
}
- while (1) {
+ do {
+ /* while (forever) { * forever is usually true,
+ but not when debugging with -exit */
/* waitpid(0, NULL, WNOHANG); */
Sleep_Interval = periodic_mail_check();
@@ -433,6 +436,9 @@ void do_biff(int argc, char **argv)
}
}
XSleep(Sleep_Interval);
+ } while (forever);
+ if (skin_xpm != NULL) {
+ free(skin_xpm); // added 3 jul 02, appeasing valgrind
}
}
@@ -927,6 +933,11 @@ void parse_cmd(int argc, char **argv, /*@out@ */ char *config_file)
i++;
}
break;
+ case 'e': /* undocumented for debugging */
+ if (strcmp(arg + 1, "exit") == 0) {
+ forever = 0;
+ }
+ break;
default:
usage();
exit(EXIT_SUCCESS);
--
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