On Wed, Nov 24, 2004 at 08:39:15PM +0100, Denis Barbier wrote:
> On Wed, Nov 24, 2004 at 06:54:04AM +0100, Christian Perrier wrote:
> [...]
> > In the future, something should be done for cdebconf handling this
> > situation better, imho. Probably make it fail rather than silently
> > exit.
>
> No, otherwise we would have to add lots of run-time checks. A better
> solution is to check that generated templates files are right, e.g.
> with help from linda/lintian.
Never mind, I was confused by mixing several bugreports.
Here is a tested patch to ignore Indices fields when they contain
invalid values.
When a (multi)select field has N items, only the first N items of
Default and Indices fields are considered, others are silently ignored.
Changing this behaviour might break other parts, so this is a feature
for now.
Message-ID: <email address hidden>
Date: Sun, 28 Nov 2004 08:53:56 +0100
From: <email address hidden> (Denis Barbier)
To: Christian Perrier <email address hidden>
Cc: Frans Pop <email address hidden>, <email address hidden>
Subject: Re: Bug#282582: Some functions in cdebconf improperly handle escaped commas
--mP3DRpeJDSE+ciuQ Disposition: inline
Content-Type: text/plain; charset=us-ascii
Content-
On Wed, Nov 24, 2004 at 08:39:15PM +0100, Denis Barbier wrote:
> On Wed, Nov 24, 2004 at 06:54:04AM +0100, Christian Perrier wrote:
> [...]
> > In the future, something should be done for cdebconf handling this
> > situation better, imho. Probably make it fail rather than silently
> > exit.
>
> No, otherwise we would have to add lots of run-time checks. A better
> solution is to check that generated templates files are right, e.g.
> with help from linda/lintian.
Never mind, I was confused by mixing several bugreports.
Here is a tested patch to ignore Indices fields when they contain
invalid values.
When a (multi)select field has N items, only the first N items of
Default and Indices fields are considered, others are silently ignored.
Changing this behaviour might break other parts, so this is a feature
for now.
Denis
--mP3DRpeJDSE+ciuQ Disposition: attachment; filename= "indices. patch"
Content-Type: text/plain; charset=us-ascii
Content-
Index: packages/ cdebconf/ src/strutl. c ======= ======= ======= ======= ======= ======= ======= ======= ==== cdebconf/ src/strutl. c (revision 24026) cdebconf/ src/strutl. c (working copy)
=======
--- packages/
+++ packages/
@@ -249,6 +249,14 @@
return argc;
}
+static int reset_index(int *oindex, size_t maxnarg) ort(const char *origbuf, const char *transbuf, const char *indices, char **oargv, char **targv, int *oindex, size_t maxnarg) (transbuf, targv, maxnarg) != maxnarg) (indices, cindex, maxnarg) != maxnarg) targv[oindex[ i]]); (indices, cindex, maxnarg) != maxnarg) {
free( cindex) ; targv[oindex[ i]]);
+{
+ int i;
+ for (i = 0; i < maxnarg; i++)
+ oindex[i] = i;
+ return maxnarg;
+}
+
int strchoicesplits
{
int i;
@@ -265,27 +273,32 @@
return DC_NOTOK;
if (strchoicesplit
return DC_NOTOK;
- if (indices == NULL || *indices == '\0') {
- for (i = 0; i < maxnarg; i++)
- oindex[i] = i;
- } else {
- cindex = malloc(sizeof(char *) * maxnarg);
- if (strchoicesplit
- return DC_NOTOK;
- sorted_targv = malloc(sizeof(char *) * maxnarg);
- for (i = 0; i < maxnarg; i++) {
- oindex[i] = strtol(cindex[i], NULL, 10) - 1;
- if (oindex[i] < 0 || oindex[i] >= maxnarg)
- return DC_NOTOK;
- sorted_targv[i] = STRDUP(
- }
- for (i = 0; i < maxnarg; i++) {
- free(targv[i]);
- targv[i] = sorted_targv[i];
- }
- free(sorted_targv);
+ if (indices == NULL || *indices == '\0')
+ return reset_index(oindex, maxnarg);
+
+ cindex = malloc(sizeof(char *) * maxnarg);
+ if (strchoicesplit
+ INFO(INFO_WARN, "Wrong number of arguments in Indices field");
+ return reset_index(oindex, maxnarg);
}
+ for (i = 0; i < maxnarg; i++) {
+ oindex[i] = strtol(cindex[i], NULL, 10) - 1;
+ if (oindex[i] < 0 || oindex[i] >= maxnarg) {
+ free(cindex);
+ INFO(INFO_WARN, "Invalid value found in Indices field: %d", oindex[i]+1);
+ return reset_index(oindex, maxnarg);
+ }
+ }
+ sorted_targv = malloc(sizeof(char *) * maxnarg);
+ for (i = 0; i < maxnarg; i++)
+ sorted_targv[i] = STRDUP(
+ for (i = 0; i < maxnarg; i++) {
+ free(targv[i]);
+ targv[i] = sorted_targv[i];
+ }
+ free(sorted_targv);
+ free(cindex);
return maxnarg;
}
--mP3DRpeJDSE+ ciuQ--