add updated ipkg conffiles patch by cdtdaddy
[openwrt.git] / package / busybox / patches / 523-conffiles_fix.patch
1 Index: busybox-1.8.2/archival/libipkg/pkg.c
2 ===================================================================
3 --- busybox-1.8.2.orig/archival/libipkg/pkg.c   2008-01-03 17:25:55.000000000 +0100
4 +++ busybox-1.8.2/archival/libipkg/pkg.c        2008-01-03 17:33:57.000000000 +0100
5 @@ -575,25 +575,28 @@
6                     return temp;
7                }
8  
9 -               len = 14 ;
10 +               len = sizeof("Conffiles:") ;
11                for (iter = pkg->conffiles.head; iter; iter = iter->next) {
12                     if (iter->data->name && iter->data->value) {
13 -                       len = len + (strlen(iter->data->name)+strlen(iter->data->value)+5);
14 -                   }
15 +                        /* " <filename> <md5hash>"  */
16 +                       len += 1+strlen(iter->data->name)+1+strlen(iter->data->value); 
17 +                    }
18                }
19 +               len +=2; /* "\n\0" */
20                 temp = (char *)realloc(temp,len);
21                 if ( temp == NULL ){
22                   fprintf(stderr, "%s: out of memory\n", __FUNCTION__);
23                   return NULL;
24                 }
25                 temp[0]='\0';
26 -               strncpy(temp, "Conffiles:\n", 12);
27 +              strcpy(temp, "Conffiles:");
28                for (iter = pkg->conffiles.head; iter; iter = iter->next) {
29                     if (iter->data->name && iter->data->value) {
30 -                         snprintf(line_str, LINE_LEN, "%s %s\n", iter->data->name, iter->data->value);
31 +                         snprintf(line_str, LINE_LEN, " %s %s", iter->data->name, iter->data->value);
32                           strncat(temp, line_str, strlen(line_str));           
33                     }
34                }
35 +               strcat(temp, "\n");
36           } else if (strcasecmp(field, "Conflicts") == 0) {
37                int i;
38  
39 Index: busybox-1.8.2/archival/libipkg/pkg_parse.c
40 ===================================================================
41 --- busybox-1.8.2.orig/archival/libipkg/pkg_parse.c     2008-01-03 17:25:55.000000000 +0100
42 +++ busybox-1.8.2/archival/libipkg/pkg_parse.c  2008-01-03 17:30:14.000000000 +0100
43  -85,20 +85,17 @@
44  {
45      char file_name[1048], md5sum[1048];  /* please tell me there aren't any longer that 1k */
46  
47 -    if(!strncmp(raw, "Conffiles:", 10))
48 +    if(!strncmp(raw, "Conffiles:",10))
49         raw += strlen("Conffiles:");
50  
51 +    while(*raw && isspace(*raw)) raw++;
52      while(*raw && (sscanf(raw, "%s%s", file_name, md5sum) == 2)){
53         conffile_list_append(&pkg->conffiles, file_name, md5sum);
54         /*      fprintf(stderr, "%s %s ", file_name, md5sum);*/
55 -       while (*raw && isspace(*raw)) {
56 -           raw++;
57 -       }
58 -       raw += strlen(file_name);
59 -       while (*raw && isspace(*raw)) {
60 -           raw++;
61 -       }
62 -       raw += strlen(md5sum);
63 +        raw += strlen(file_name);
64 +       while(*raw && isspace(*raw)) raw++;
65 +        raw += strlen(md5sum);
66 +        while(*raw && isspace(*raw)) raw++;
67      }
68  }