Skip to content

Commit 9922b6b

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. This also removes the 1024 byte limit for nxagentOptionsFilenameOrString.
1 parent dd67a34 commit 9922b6b

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
@@ -247,14 +247,21 @@ int ddxProcessArgument(int argc, char *argv[], int i)
247247

248248
for (j = 0; j < argc; j++)
249249
{
250+
/*
251+
* Read the _last_ options file only and only at startup.
252+
253+
* This had to be '-options' since the beginning
254+
* but was '-option' by mistake. Now we have to
255+
* handle the backward compatibility.
256+
*/
250257
if ((!strcmp(argv[j], "-options") || !strcmp(argv[j], "-option")) && j + 1 < argc)
251258
{
252259
free(nxagentOptionsFilenameOrString);
253260
if ((nxagentOptionsFilenameOrString = strdup(argv[j + 1])) == NULL)
254261
{
255262
FatalError("malloc for -options failed");
256263
}
257-
break;
264+
j++;
258265
}
259266
}
260267

@@ -311,36 +318,17 @@ int ddxProcessArgument(int argc, char *argv[], int i)
311318
}
312319

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

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

0 commit comments

Comments
 (0)