Skip to content

Commit e187f54

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 ea9a206 commit e187f54

File tree

1 file changed

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

1 file changed

+16
-21
lines changed

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

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

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

@@ -319,29 +326,17 @@ int ddxProcessArgument(int argc, char *argv[], int i)
319326
}
320327

321328
/*
322-
* This had to be '-options' since the beginning
323-
* but was '-option' by mistake. Now we have to
324-
* handle the backward compatibility.
329+
* an options string/filename can only be provided via the command
330+
* line or environment. Both are handled above in the one-time init
331+
* part and will not change during runtime. As we do not want an
332+
* options file to include another "options" option we skip this
333+
* here. Due to the way nxagent handles all this option stuff we
334+
* cannot remove the check completely.
325335
*/
326-
327336
if (!strcmp(argv[i], "-options") || !strcmp(argv[i], "-option"))
328337
{
329-
if (++i < argc)
330-
{
331-
free(nxagentOptionsFilenameOrString);
332-
nxagentOptionsFilenameOrString = NULL;
333-
334-
/* FIXME: why limit 10 1024 bytes? */
335-
if ((size = strlen(argv[i])) < 1024)
336-
{
337-
if ((nxagentOptionsFilenameOrString = strndup(argv[i], size)) == NULL)
338-
{
339-
FatalError("malloc for -options failed");
340-
}
341-
}
342-
return 2;
343-
}
344-
return 0;
338+
/* skip -options and its argument */
339+
return 2;
345340
}
346341

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

0 commit comments

Comments
 (0)