json-glib: update to 1.10.6
[oi-userland.git] / components / mail / mpack / patches / patch-ag.patch
blob3cb14094f3fa8aff67d55d59ed1c931755d665b1
1 $NetBSD: patch-ag,v 1.2 2012/02/22 21:01:53 shattered Exp $
3 --- decode.c.orig 2003-07-21 20:47:54.000000000 +0000
4 +++ decode.c
5 @@ -25,6 +25,7 @@
6 * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
7 * SOFTWARE. */
9 +#include <errno.h>
10 #include <stdio.h>
11 #include <string.h>
12 #include <ctype.h>
13 @@ -545,8 +546,8 @@ getDispositionFilename(char *disposition
14 SkipWhitespace(&disposition);
15 if (!disposition) return 0;
17 - /* If we're looking at a ";", we found what we're looking for */
18 - if (*disposition++ == ';') break;
19 + /* If we're looking at a "=", we found what we're looking for */
20 + if (*disposition++ == '=') break;
23 SkipWhitespace(&disposition);
24 @@ -601,7 +602,7 @@ int handlePartial(struct part *inpart, c
26 char *id, *dir, *p;
27 int thispart;
28 - int nparts = 0;
29 + int nparts = 0, onparts=0;
30 char buf[1024];
31 FILE *partfile, *outfile;
32 struct part *outpart;
33 @@ -624,33 +625,44 @@ int handlePartial(struct part *inpart, c
35 thispart = atoi(p);
37 + /* Try to retrieve number of parts from reassembly directory */
38 + sprintf(buf, "%sCT", dir);
39 + if (partfile = fopen(buf, "r")) {
40 + if (fgets(buf, sizeof(buf), partfile)) {
41 + onparts = atoi(buf);
42 + if (onparts < 0) onparts = 0;
43 + }
44 + fclose(partfile);
45 + }
47 if (p = getParam(contentParams, "total")) {
48 nparts = atoi(p);
49 if (nparts <= 0) {
50 warn("partial message has invalid number of parts");
51 goto ignore;
53 - /* Store number of parts in reassembly directory */
54 - sprintf(buf, "%sCT", dir);
55 - partfile = os_createnewfile(buf);
56 - if (!partfile) {
57 - os_perror(buf);
58 + if (onparts && nparts && nparts != onparts) {
59 + warn("messages disagree about total number of parts");
60 goto ignore;
62 - fprintf(partfile, "%d\n", nparts);
63 - fclose(partfile);
64 - }
65 - else {
66 - /* Try to retrieve number of parts from reassembly directory */
68 + /* Store number of parts in reassembly directory */
69 sprintf(buf, "%sCT", dir);
70 - if (partfile = fopen(buf, "r")) {
71 - if (fgets(buf, sizeof(buf), partfile)) {
72 - nparts = atoi(buf);
73 - if (nparts < 0) nparts = 0;
74 + partfile = fopen(buf, "w");
75 + if (!partfile) {
76 + if (errno != EEXIST) {
77 + os_perror(buf);
78 + goto ignore;
80 + onparts = nparts;
81 + } else {
82 + fprintf(partfile, "%d\n", nparts);
83 fclose(partfile);
86 + else {
87 + nparts = onparts;
88 + }
90 /* Sanity check */
91 if (thispart <= 0 || (nparts && thispart > nparts)) {