Skip to content

Commit 836225d

Browse files
committed
Args.c: do not handle -options twice
An options string/filename can only be provided via the command line or environment. Both are handled in the one-time init part of ddxProcessArguments() and will not change during runtime. As we do not want an options file to include another "options" option there's no need to handle that a second time. Due to the (kind of crazy) way nxagent handles all this option stuff we cannot remove the second check completely.
1 parent 399860a commit 836225d

File tree

1 file changed

+16
-28
lines changed
  • nx-X11/programs/Xserver/hw/nxagent

1 file changed

+16
-28
lines changed

nx-X11/programs/Xserver/hw/nxagent/Args.c

Lines changed: 16 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -250,14 +250,21 @@ int ddxProcessArgument(int argc, char *argv[], int i)
250250

251251
for (j = 0; j < argc; j++)
252252
{
253+
/*
254+
* Read the _last_ options file only and only at startup.
255+
256+
* This had to be '-options' since the beginning
257+
* but was '-option' by mistake. Now we have to
258+
* handle the backward compatibility.
259+
*/
253260
if ((!strcmp(argv[j], "-options") || !strcmp(argv[j], "-option")) && j + 1 < argc)
254261
{
255262
free(nxagentOptionsFilenameOrString);
256263
if ((nxagentOptionsFilenameOrString = strdup(argv[j + 1])) == NULL)
257264
{
258265
FatalError("malloc for -options failed");
259266
}
260-
break;
267+
j++;
261268
}
262269
}
263270

@@ -314,36 +321,17 @@ int ddxProcessArgument(int argc, char *argv[], int i)
314321
}
315322

316323
/*
317-
* This had to be '-options' since the beginning
318-
* but was '-option' by mistake. Now we have to
319-
* handle the backward compatibility.
324+
* an options string/filename can only be provided via the command
325+
* line or environment. Both are handled above in the one-time init
326+
* part and will not change during runtime. As we do not want an
327+
* options file to include another "options" option we skip this
328+
* here. Due to the way nxagent handles all this option stuff we
329+
* cannot remove the check completely.
320330
*/
321-
322331
if (!strcmp(argv[i], "-options") || !strcmp(argv[i], "-option"))
323332
{
324-
if (++i < argc)
325-
{
326-
int size;
327-
328-
free(nxagentOptionsFilenameOrString);
329-
nxagentOptionsFilenameOrString = NULL;
330-
331-
/* FIXME: why limit 10 1024 bytes? */
332-
if ((size = strlen(argv[i])) < 1024)
333-
{
334-
if ((nxagentOptionsFilenameOrString = strndup(argv[i], size)) == NULL)
335-
{
336-
FatalError("malloc for -options failed");
337-
}
338-
}
339-
else
340-
{
341-
/* there's no use in ignoring the whole options string or file */
342-
FatalError("options parameter is too long");
343-
}
344-
return 2;
345-
}
346-
return 0;
333+
/* skip -options and its argument */
334+
return 2;
347335
}
348336

349337
if (!strcmp(argv[i], "-sync")) {

0 commit comments

Comments
 (0)