[pan2/testing: 148/279] fixed uudeview bug that didn't initialize the crc32 checksum in uuencodepartial
- From: Heinrich MÃller <henmull src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pan2/testing: 148/279] fixed uudeview bug that didn't initialize the crc32 checksum in uuencodepartial
- Date: Sat, 3 Dec 2011 22:34:37 +0000 (UTC)
commit 0f0b6b6bd4406aabc1006ac0177a40947877674b
Author: Heinrich MÃller <sphemuel stud informatik uni-erlangen de>
Date: Mon Jul 4 14:03:51 2011 +0200
fixed uudeview bug that didn't initialize the crc32 checksum in
uuencodepartial
pan/tasks/encoder.cc | 15 +++++----------
pan/tasks/task-upload.cc | 4 ++--
uulib/uudeview.h | 3 +--
uulib/uuencode.c | 6 ++++--
uulib/uunconc.c | 35 ++++++++++++++++++-----------------
5 files changed, 30 insertions(+), 33 deletions(-)
---
diff --git a/pan/tasks/encoder.cc b/pan/tasks/encoder.cc
index 8c9446b..4fbef63 100644
--- a/pan/tasks/encoder.cc
+++ b/pan/tasks/encoder.cc
@@ -98,11 +98,10 @@ Encoder :: do_work()
const int bufsz = 4096;
char buf[bufsz], buf2[bufsz];
int cnt(1);
- crc32_t crc;
+ crc32_t crc(0);
struct stat sb;
std::string s;
FILE* outfile, * infile ;
-// PartBatch batch;
char cachename[4096];
FILE * fp ;
Article* tmp = article;
@@ -117,8 +116,6 @@ Encoder :: do_work()
UUSetMsgCallback (this, uu_log);
UUSetBusyCallback (this, uu_busy_poll, 200);
-// batch.init(StringView(basename), needed->size(), 0);
-
/* build real subject line for article*/
tmp->subject = subject;
@@ -127,8 +124,6 @@ Encoder :: do_work()
int enc(YENC_ENCODED);
std::ofstream out;
std::string txt;
- /* (encoding!=UU_ENCODED&&encoding!=XX_ENCODED&&encoding!=B64ENCODED&&
- encoding!=PT_ENCODED&&encoding!=QP_ENCODED&&encoding!=YENC_ENCODED)) { */
switch (encode_mode)
{
case TaskUpload::YENC:
@@ -159,7 +154,7 @@ Encoder :: do_work()
continue;
}
- res = UUEncodePartial (fp, NULL, (char*)filename.c_str(), enc , (char*)basename.c_str(), NULL, 0644, cnt, lpf,&crc);
+ res = UUEncodePartial (fp, NULL, (char*)filename.c_str(), enc , (char*)basename.c_str(), 0, 0, cnt, lpf, &crc);
if (fp) fclose(fp);
_no_encode:
@@ -185,12 +180,12 @@ _no_encode:
: UUstrerror(res));
log_errors.push_back(buf); // log error
} else
- { // prepare article for upload list
-// tmp->set_parts(batch);
task->_upload_list.push_back(tmp);
- }
+
UUCleanUp ();
+
}
+
disable_progress_update();
}
diff --git a/pan/tasks/task-upload.cc b/pan/tasks/task-upload.cc
index 8f4525a..32db857 100644
--- a/pan/tasks/task-upload.cc
+++ b/pan/tasks/task-upload.cc
@@ -419,6 +419,6 @@ TaskUpload :: ~TaskUpload ()
_encoder->cancel_silently();
g_object_unref (G_OBJECT(_msg));
- _cache.release(_mids);
- _cache.resize();
+// _cache.release(_mids);
+// _cache.resize();
}
diff --git a/uulib/uudeview.h b/uulib/uudeview.h
index 428eaa1..fec8324 100644
--- a/uulib/uudeview.h
+++ b/uulib/uudeview.h
@@ -227,8 +227,7 @@ int UUEXPORT UUEncodeMulti _ANSI_ARGS_((FILE *, FILE *,
int UUEXPORT UUEncodePartial _ANSI_ARGS_((FILE *, FILE *,
char *, int,
char *, char *,
- int, int, long,
- unsigned long*));
+ int, int, long, unsigned long*));
int UUEXPORT UUEncodeToStream _ANSI_ARGS_((FILE *, FILE *,
char *, int,
char *, int));
diff --git a/uulib/uuencode.c b/uulib/uuencode.c
index 20e1f37..ac9a054 100644
--- a/uulib/uuencode.c
+++ b/uulib/uuencode.c
@@ -788,8 +788,7 @@ int UUEXPORT
UUEncodePartial (FILE *outfile, FILE *infile,
char *infname, int encoding,
char *outfname, char *mimetype,
- int filemode, int partno, long linperfile,
- crc32_t *crcptr)
+ int filemode, int partno, long linperfile, unsigned long* crcptr)
{
mimemap *miter=mimetable;
static FILE *theifile;
@@ -817,6 +816,8 @@ UUEncodePartial (FILE *outfile, FILE *infile,
progress.action = 0;
if (partno == 1) {
+ *crcptr = crc32(0L, Z_NULL, 0);
+
if (infile==NULL) {
if (stat (infname, &finfo) == -1) {
UUMessage (uuencode_id, __LINE__, UUMSG_ERROR,
@@ -971,6 +972,7 @@ UUEncodePartial (FILE *outfile, FILE *infile,
progress.action = UUACT_ENCODING;
+ /// DBG
if ((res = UUEncodeStream (outfile, theifile, encoding, linperfile,
crcptr, pcrcptr)) != UURET_OK) {
if (infile==NULL) fclose (theifile);
diff --git a/uulib/uunconc.c b/uulib/uunconc.c
index 4eeae88..a918b6f 100644
--- a/uulib/uunconc.c
+++ b/uulib/uunconc.c
@@ -222,7 +222,7 @@ UUBrokenByNetscape (char *string)
* Try to repair a Netscape-corrupted line of data.
* This must only be called on corrupted lines, since non-Netscape
* data may even _get_ corrupted by this procedure.
- *
+ *
* Some checks are included multiply to speed up the procedure. For
* example: (*p1!='<' || strnicmp(p1,"</a>",4)). If the first expression
* becomes true, the costly function isn't called :-)
@@ -262,7 +262,7 @@ UUNetscapeCollapse (char *string)
while (*p1) {
if (*p1 == '<') {
if ((_FP_strnicmp (p1, "<ahref=", 7) == 0 ||
- _FP_strnicmp (p1, "<a href=",8) == 0) &&
+ _FP_strnicmp (p1, "<a href=",8) == 0) &&
(_FP_strstr (p1, "</a>") != 0 || _FP_strstr (p1, "</A>") != 0)) {
while (*p1 && *p1!='>') p1++;
if (*p1=='\0' || *(p1+1)!='<') return 0;
@@ -634,20 +634,20 @@ UUDecodeLine (char *s, char *d, int method)
if(i-- > 0)
d[count++] = c;
-
+
cc <<= 4;
c = table[ACAST(*s++)];
cc |= (c >> 2);
-
+
if(i-- > 0)
d[count++] = cc;
-
+
c <<= 6;
c |= table[ACAST(*s++)];
-
+
if(i-- > 0)
d[count++] = c;
-
+
j -= 4;
}
}
@@ -747,7 +747,7 @@ UUDecodeQP (FILE *datain, FILE *dataout, int *state,
uulboundary = -1;
- while (!feof (datain) &&
+ while (!feof (datain) &&
(ftell(datain)<maxpos || flags&FL_TOEND ||
(!(flags&FL_PROPER) && uu_fast_scanning))) {
if (_FP_fgets (line, 255, datain) == NULL)
@@ -821,7 +821,7 @@ UUDecodeQP (FILE *datain, FILE *dataout, int *state,
* encapsulation line is conceptually attached to the boundary.
* So if the part ends here, don't print a line break"
*/
- if (val && (!feof (datain) &&
+ if (val && (!feof (datain) &&
(ftell(datain)<maxpos || flags&FL_TOEND ||
(!(flags&FL_PROPER) && uu_fast_scanning))))
fprintf (dataout, "%s\n", p1);
@@ -844,7 +844,7 @@ UUDecodePT (FILE *datain, FILE *dataout, int *state,
uulboundary = -1;
- while (!feof (datain) &&
+ while (!feof (datain) &&
(ftell(datain)<maxpos || flags&FL_TOEND ||
(!(flags&FL_PROPER) && uu_fast_scanning))) {
if (_FP_fgets (line, 255, datain) == NULL)
@@ -1005,7 +1005,7 @@ UUDecodePart (FILE *datain, FILE *dataout, int *state,
*state = BEGIN;
}
- while (!feof (datain) && *state != DONE &&
+ while (!feof (datain) && *state != DONE &&
(ftell(datain)<maxpos || flags&FL_TOEND || maxpos==-1 ||
(!(flags&FL_PROPER) && uu_fast_scanning))) {
if (_FP_fgets (line, line_len, datain) == NULL)
@@ -1035,7 +1035,7 @@ UUDecodePart (FILE *datain, FILE *dataout, int *state,
vlc = 0;
continue;
}
-
+
/*
* Busy Polls
*/
@@ -1124,7 +1124,7 @@ UUDecodePart (FILE *datain, FILE *dataout, int *state,
if ((ptr = _FP_strstr (line, " end=")) == NULL) {
break;
}
-
+
yepartends = atoi (ptr + 5);
}
tf = 1;
@@ -1133,7 +1133,7 @@ UUDecodePart (FILE *datain, FILE *dataout, int *state,
else {
continue;
}
-
+
tc = tf = vlc = 0;
lc[0] = lc[1] = 0;
}
@@ -1157,6 +1157,7 @@ UUDecodePart (FILE *datain, FILE *dataout, int *state,
if ((ptr = _FP_strstr (line, " crc32=")) != NULL)
{
crc32_t fcrc32 = strtoul (ptr + 7, NULL, 16);
+ printf("%lu %lu\n",fcrc32, yefilecrc);
if (fcrc32 != yefilecrc) {
UUMessage (uunconc_id, __LINE__, UUMSG_WARNING,
uustring (S_CRC_MISMATCH), progress.curfile);
@@ -1279,7 +1280,7 @@ UUDecodePart (FILE *datain, FILE *dataout, int *state,
if (*state == DONE ||
(*state == DATA && method == B64ENCODED &&
vflag == B64ENCODED && (flags&FL_PROPER || haddh))) {
- for (tf=0; tf<tc; tf++)
+ for (tf=0; tf<tc; tf++)
count += UUDecodeLine (save[tf], oline + count, method);
if (count) {
if (method == BH_ENCODED) {
@@ -1414,7 +1415,7 @@ UUDecode (uulist *data)
progress.numparts = (iter->partno)?iter->partno:1;
iter = iter->NEXT;
}
-
+
/*
* let's rock!
*/
@@ -1486,7 +1487,7 @@ UUDecode (uulist *data)
iter = iter->NEXT;
}
- if (state == DATA &&
+ if (state == DATA &&
(data->uudet == B64ENCODED || data->uudet == QP_ENCODED ||
data->uudet == PT_ENCODED))
state = DONE; /* assume we're done */
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]