Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nx-libs
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
dimbor
nx-libs
Commits
ea1e0bea
Commit
ea1e0bea
authored
Jan 02, 2018
by
Ulrich Sibiller
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replace hardcoded string lengths by macros
parent
9a6b90c3
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
43 additions
and
69 deletions
+43
-69
Args.c
nx-X11/programs/Xserver/hw/nxagent/Args.c
+18
-53
Args.h
nx-X11/programs/Xserver/hw/nxagent/Args.h
+11
-5
Dialog.c
nx-X11/programs/Xserver/hw/nxagent/Dialog.c
+4
-4
Dialog.h
nx-X11/programs/Xserver/hw/nxagent/Dialog.h
+4
-2
Display.c
nx-X11/programs/Xserver/hw/nxagent/Display.c
+1
-1
NXdixfonts.c
nx-X11/programs/Xserver/hw/nxagent/NXdixfonts.c
+5
-4
No files found.
nx-X11/programs/Xserver/hw/nxagent/Args.c
View file @
ea1e0bea
...
@@ -126,15 +126,15 @@ extern char dispatchExceptionAtReset;
...
@@ -126,15 +126,15 @@ extern char dispatchExceptionAtReset;
extern
const
char
*
__progname
;
extern
const
char
*
__progname
;
char
nxagentDisplayName
[
1024
];
char
nxagentDisplayName
[
NXAGENTDISPLAYNAMELENGTH
];
Bool
nxagentSynchronize
=
False
;
Bool
nxagentSynchronize
=
False
;
Bool
nxagentRealWindowProp
=
False
;
Bool
nxagentRealWindowProp
=
False
;
char
nxagentShadowDisplayName
[
1024
]
=
{
0
};
char
nxagentShadowDisplayName
[
NXAGENTSHADOWDISPLAYNAMELENGTH
]
=
{
0
};
char
nxagentWindowName
[
256
];
char
nxagentWindowName
[
NXAGENTWINDOWNAMELENGTH
];
char
nxagentDialogName
[
256
];
char
nxagentDialogName
[
NXAGENTDIALOGNAMELENGTH
];
char
nxagentSessionId
[
256
]
=
{
0
};
char
nxagentSessionId
[
NXAGENTSESSIONIDLENGTH
]
=
{
0
};
char
*
nxagentOptionsFilenameOrString
;
char
*
nxagentOptionsFilenameOrString
;
Bool
nxagentFullGeneration
=
False
;
Bool
nxagentFullGeneration
=
False
;
...
@@ -326,10 +326,7 @@ int ddxProcessArgument(int argc, char *argv[], int i)
...
@@ -326,10 +326,7 @@ int ddxProcessArgument(int argc, char *argv[], int i)
{
{
if
(
++
i
<
argc
)
if
(
++
i
<
argc
)
{
{
strncpy
(
nxagentDisplayName
,
argv
[
i
],
1023
);
snprintf
(
nxagentDisplayName
,
NXAGENTDISPLAYNAMELENGTH
,
"%s"
,
argv
[
i
]);
nxagentDisplayName
[
1023
]
=
'\0'
;
return
2
;
return
2
;
}
}
...
@@ -340,10 +337,7 @@ int ddxProcessArgument(int argc, char *argv[], int i)
...
@@ -340,10 +337,7 @@ int ddxProcessArgument(int argc, char *argv[], int i)
{
{
if
(
++
i
<
argc
)
if
(
++
i
<
argc
)
{
{
strncpy
(
nxagentSessionId
,
argv
[
i
],
255
);
snprintf
(
nxagentSessionId
,
NXAGENTSESSIONIDLENGTH
,
"%s"
,
argv
[
i
]);
*
(
nxagentSessionId
+
255
)
=
'\0'
;
return
2
;
return
2
;
}
}
...
@@ -360,35 +354,13 @@ int ddxProcessArgument(int argc, char *argv[], int i)
...
@@ -360,35 +354,13 @@ int ddxProcessArgument(int argc, char *argv[], int i)
{
{
if
(
++
i
<
argc
)
if
(
++
i
<
argc
)
{
{
int
size
;
free
(
nxagentOptionsFilenameOrString
);
free
(
nxagentOptionsFilenameOrString
);
nxagentOptionsFilenameOrString
=
NULL
;
nxagentOptionsFilenameOrString
=
NULL
;
if
(
(
size
=
strlen
(
argv
[
i
]))
<
1024
)
if
(
-
1
==
asprintf
(
&
nxagentOptionsFilenameOrString
,
"%s"
,
argv
[
i
])
)
{
{
if
((
nxagentOptionsFilenameOrString
=
malloc
(
size
+
1
))
==
NULL
)
FatalError
(
"malloc failed"
);
{
FatalError
(
"malloc failed"
);
}
strncpy
(
nxagentOptionsFilenameOrString
,
argv
[
i
],
size
);
nxagentOptionsFilenameOrString
[
size
]
=
'\0'
;
}
}
else
{
/*
* It is useless to store the file name
* that has just been truncated.
*/
#ifdef WARNING
fprintf
(
stderr
,
"ddxProcessArgument: WARNING! Option file name "
"too long. It will be ignored.
\n
"
);
#endif
}
return
2
;
return
2
;
}
}
...
@@ -670,10 +642,7 @@ int ddxProcessArgument(int argc, char *argv[], int i)
...
@@ -670,10 +642,7 @@ int ddxProcessArgument(int argc, char *argv[], int i)
{
{
if
(
++
i
<
argc
)
if
(
++
i
<
argc
)
{
{
strncpy
(
nxagentWindowName
,
argv
[
i
],
255
);
snprintf
(
nxagentWindowName
,
NXAGENTWINDOWNAMELENGTH
,
"%s"
,
argv
[
i
]);
*
(
nxagentWindowName
+
255
)
=
'\0'
;
return
2
;
return
2
;
}
}
...
@@ -903,15 +872,13 @@ int ddxProcessArgument(int argc, char *argv[], int i)
...
@@ -903,15 +872,13 @@ int ddxProcessArgument(int argc, char *argv[], int i)
{
{
if
(
++
i
<
argc
)
if
(
++
i
<
argc
)
{
{
s
trncpy
(
nxagentShadowDisplayName
,
argv
[
i
],
1023
);
s
nprintf
(
nxagentShadowDisplayName
,
NXAGENTSHADOWDISPLAYNAMELENGTH
,
"%s"
,
argv
[
i
]
);
if
(
strcmp
(
nxagentShadowDisplayName
,
""
)
==
0
)
if
(
strcmp
(
nxagentShadowDisplayName
,
""
)
==
0
)
{
{
FatalError
(
"Invalid shadow display option"
);
FatalError
(
"Invalid shadow display option"
);
}
}
*
(
nxagentShadowDisplayName
+
1023
)
=
'\0'
;
return
2
;
return
2
;
}
}
...
@@ -1780,9 +1747,7 @@ N/A
...
@@ -1780,9 +1747,7 @@ N/A
if
(
*
nxagentWindowName
==
'\0'
)
if
(
*
nxagentWindowName
==
'\0'
)
{
{
strncpy
(
nxagentWindowName
,
"NX"
,
255
);
snprintf
(
nxagentWindowName
,
NXAGENTWINDOWNAMELENGTH
,
"NX"
);
*
(
nxagentWindowName
+
255
)
=
'\0'
;
}
}
/*
/*
...
@@ -2161,9 +2126,7 @@ void ddxUseMsg()
...
@@ -2161,9 +2126,7 @@ void ddxUseMsg()
static
int
nxagentGetDialogName
()
static
int
nxagentGetDialogName
()
{
{
strcpy
(
nxagentDialogName
,
"NX"
);
snprintf
(
nxagentDialogName
,
NXAGENTDIALOGNAMELENGTH
,
"NX"
);
*
(
nxagentDialogName
+
255
)
=
'\0'
;
if
(
*
nxagentSessionId
!=
'\0'
)
if
(
*
nxagentSessionId
!=
'\0'
)
{
{
...
@@ -2171,17 +2134,19 @@ static int nxagentGetDialogName()
...
@@ -2171,17 +2134,19 @@ static int nxagentGetDialogName()
strcpy
(
nxagentDialogName
,
"NX - "
);
strcpy
(
nxagentDialogName
,
"NX - "
);
/* if the session id contains an MD5 hash in a well-known format cut it off */
if
(
length
>
(
MD5_LENGTH
*
2
+
1
)
&&
if
(
length
>
(
MD5_LENGTH
*
2
+
1
)
&&
*
(
nxagentSessionId
+
(
length
-
(
MD5_LENGTH
*
2
+
1
)))
==
'-'
)
*
(
nxagentSessionId
+
(
length
-
(
MD5_LENGTH
*
2
+
1
)))
==
'-'
)
{
{
strncat
(
nxagentDialogName
,
nxagentSessionId
,
length
-
(
MD5_LENGTH
*
2
+
1
));
strncat
(
nxagentDialogName
,
nxagentSessionId
,
MIN
(
NXAGENTDIALOGNAMELENGTH
-
strlen
(
nxagentDialogName
),
length
-
(
MD5_LENGTH
*
2
+
1
))
-
1
);
}
}
else
else
{
{
strncat
(
nxagentDialogName
,
nxagentSessionId
,
250
);
strncat
(
nxagentDialogName
,
nxagentSessionId
,
NXAGENTDIALOGNAMELENGTH
-
strlen
(
nxagentDialogName
)
-
1
);
}
}
*
(
nxagentSessionId
+
255
)
=
'\0'
;
nxagentDialogName
[
NXAGENTDIALOGNAMELENGTH
-
1
]
=
'\0'
;
return
1
;
return
1
;
}
}
...
...
nx-X11/programs/Xserver/hw/nxagent/Args.h
View file @
ea1e0bea
...
@@ -52,11 +52,17 @@ struct UserGeometry{
...
@@ -52,11 +52,17 @@ struct UserGeometry{
extern
Bool
nxagentUseNXTrans
;
extern
Bool
nxagentUseNXTrans
;
extern
char
nxagentSessionId
[];
#define NXAGENTSESSIONIDLENGTH 256
extern
char
nxagentDisplayName
[
1024
];
#define NXAGENTDISPLAYNAMELENGTH 1024
extern
char
nxagentShadowDisplayName
[];
#define NXAGENTSHADOWDISPLAYNAMELENGTH 1024
extern
char
nxagentWindowName
[];
#define NXAGENTWINDOWNAMELENGTH 256
extern
char
nxagentDialogName
[];
#define NXAGENTDIALOGNAMELENGTH 256
extern
char
nxagentSessionId
[
NXAGENTSESSIONIDLENGTH
];
extern
char
nxagentDisplayName
[
NXAGENTDISPLAYNAMELENGTH
];
extern
char
nxagentShadowDisplayName
[
NXAGENTSHADOWDISPLAYNAMELENGTH
];
extern
char
nxagentWindowName
[
NXAGENTWINDOWNAMELENGTH
];
extern
char
nxagentDialogName
[
NXAGENTDIALOGNAMELENGTH
];
extern
Bool
nxagentSynchronize
;
extern
Bool
nxagentSynchronize
;
extern
Bool
nxagentRealWindowProp
;
extern
Bool
nxagentRealWindowProp
;
...
...
nx-X11/programs/Xserver/hw/nxagent/Dialog.c
View file @
ea1e0bea
...
@@ -66,9 +66,9 @@ int nxagentDisableDeferModePid = 0;
...
@@ -66,9 +66,9 @@ int nxagentDisableDeferModePid = 0;
static
int
nxagentFailedReconnectionDialogPid
=
0
;
static
int
nxagentFailedReconnectionDialogPid
=
0
;
char
nxagentPulldownWindow
[
16
];
char
nxagentPulldownWindow
[
NXAGENTPULLDOWNWINDOWLENGTH
];
char
nxagentFailedReconnectionMessage
[
256
];
char
nxagentFailedReconnectionMessage
[
NXAGENTFAILEDRECONNECTIONMESSAGELENGTH
];
void
nxagentResetDialog
(
int
pid
)
void
nxagentResetDialog
(
int
pid
)
{
{
...
@@ -317,7 +317,7 @@ void nxagentLaunchDialog(DialogType dialogType)
...
@@ -317,7 +317,7 @@ void nxagentLaunchDialog(DialogType dialogType)
void
nxagentPulldownDialog
(
Window
wid
)
void
nxagentPulldownDialog
(
Window
wid
)
{
{
snprintf
(
nxagentPulldownWindow
,
sizeof
(
nxagentPulldownWindow
)
,
"%ld"
,
(
long
int
)
wid
);
snprintf
(
nxagentPulldownWindow
,
NXAGENTPULLDOWNWINDOWLENGTH
,
"%ld"
,
(
long
int
)
wid
);
#ifdef TEST
#ifdef TEST
fprintf
(
stderr
,
"nxagentPulldownDialog: Going to launch pulldown "
fprintf
(
stderr
,
"nxagentPulldownDialog: Going to launch pulldown "
...
@@ -368,7 +368,7 @@ void nxagentFailedReconnectionDialog(int alert, char *error)
...
@@ -368,7 +368,7 @@ void nxagentFailedReconnectionDialog(int alert, char *error)
int
status
;
int
status
;
int
options
=
0
;
int
options
=
0
;
snprintf
(
nxagentFailedReconnectionMessage
,
sizeof
(
nxagentFailedReconnectionMessage
)
,
"Reconnection failed: %s"
,
error
);
snprintf
(
nxagentFailedReconnectionMessage
,
NXAGENTFAILEDRECONNECTIONMESSAGELENGTH
,
"Reconnection failed: %s"
,
error
);
nxagentLaunchDialog
(
DIALOG_FAILED_RECONNECTION
);
nxagentLaunchDialog
(
DIALOG_FAILED_RECONNECTION
);
...
...
nx-X11/programs/Xserver/hw/nxagent/Dialog.h
View file @
ea1e0bea
...
@@ -55,9 +55,11 @@ extern int nxagentDisableRandRModeDialogPid;
...
@@ -55,9 +55,11 @@ extern int nxagentDisableRandRModeDialogPid;
extern
int
nxagentEnableDeferModePid
;
extern
int
nxagentEnableDeferModePid
;
extern
int
nxagentDisableDeferModePid
;
extern
int
nxagentDisableDeferModePid
;
extern
char
nxagentFailedReconnectionMessage
[];
#define NXAGENTFAILEDRECONNECTIONMESSAGELENGTH 256
extern
char
nxagentFailedReconnectionMessage
[
NXAGENTFAILEDRECONNECTIONMESSAGELENGTH
];
extern
char
nxagentPulldownWindow
[];
#define NXAGENTPULLDOWNWINDOWLENGTH 16
extern
char
nxagentPulldownWindow
[
NXAGENTPULLDOWNWINDOWLENGTH
];
extern
void
nxagentLaunchDialog
(
DialogType
type
);
extern
void
nxagentLaunchDialog
(
DialogType
type
);
extern
void
nxagentResetDialog
(
int
pid
);
extern
void
nxagentResetDialog
(
int
pid
);
...
...
nx-X11/programs/Xserver/hw/nxagent/Display.c
View file @
ea1e0bea
...
@@ -1150,7 +1150,7 @@ void nxagentOpenDisplay(int argc, char *argv[])
...
@@ -1150,7 +1150,7 @@ void nxagentOpenDisplay(int argc, char *argv[])
if
(
*
nxagentDisplayName
==
'\0'
)
if
(
*
nxagentDisplayName
==
'\0'
)
{
{
snprintf
(
nxagentDisplayName
,
sizeof
(
nxagentDisplayName
)
,
"%s"
,
XDisplayName
(
NULL
));
snprintf
(
nxagentDisplayName
,
NXAGENTDISPLAYNAMELENGTH
,
"%s"
,
XDisplayName
(
NULL
));
}
}
nxagentCloseDisplay
();
nxagentCloseDisplay
();
...
...
nx-X11/programs/Xserver/hw/nxagent/NXdixfonts.c
View file @
ea1e0bea
...
@@ -96,7 +96,8 @@ static Bool doListFontsAndAliases(ClientPtr client, LFclosurePtr c);
...
@@ -96,7 +96,8 @@ static Bool doListFontsAndAliases(ClientPtr client, LFclosurePtr c);
#ifdef NX_TRANS_SOCKET
#ifdef NX_TRANS_SOCKET
char
_NXFontPath
[
1024
];
#define NXFONTPATHLENGTH 1024
char
_NXFontPath
[
NXFONTPATHLENGTH
];
/*
/*
* Override the default font path and make
* Override the default font path and make
...
@@ -121,7 +122,7 @@ static const char *_NXGetFontPath(const char *path)
...
@@ -121,7 +122,7 @@ static const char *_NXGetFontPath(const char *path)
if
(
fontEnv
!=
NULL
&&
*
fontEnv
!=
'\0'
)
if
(
fontEnv
!=
NULL
&&
*
fontEnv
!=
'\0'
)
{
{
if
(
strlen
(
fontEnv
)
+
1
>
sizeof
(
_NXFontPath
)
)
if
(
strlen
(
fontEnv
)
+
1
>
NXFONTPATHLENGTH
)
{
{
#ifdef NX_TRANS_TEST
#ifdef NX_TRANS_TEST
fprintf
(
stderr
,
"_NXGetFontPath: WARNING! Maximum length of font path exceeded.
\n
"
);
fprintf
(
stderr
,
"_NXGetFontPath: WARNING! Maximum length of font path exceeded.
\n
"
);
...
@@ -129,7 +130,7 @@ static const char *_NXGetFontPath(const char *path)
...
@@ -129,7 +130,7 @@ static const char *_NXGetFontPath(const char *path)
goto
_NXGetFontPathError
;
goto
_NXGetFontPathError
;
}
}
s
trcpy
(
_NXFontPath
,
fontEnv
);
s
nprintf
(
_NXFontPath
,
NXFONTPATHLENGTH
,
"%s"
,
fontEnv
);
#ifdef NX_TRANS_TEST
#ifdef NX_TRANS_TEST
fprintf
(
stderr
,
"_NXGetFontPath: Using NX font path [%s].
\n
"
,
_NXFontPath
);
fprintf
(
stderr
,
"_NXGetFontPath: Using NX font path [%s].
\n
"
,
_NXFontPath
);
...
@@ -140,7 +141,7 @@ static const char *_NXGetFontPath(const char *path)
...
@@ -140,7 +141,7 @@ static const char *_NXGetFontPath(const char *path)
_NXGetFontPathError:
_NXGetFontPathError:
snprintf
(
_NXFontPath
,
sizeof
(
_NXFontPath
)
,
"%s"
,
path
);
snprintf
(
_NXFontPath
,
NXFONTPATHLENGTH
,
"%s"
,
path
);
#ifdef NX_TRANS_TEST
#ifdef NX_TRANS_TEST
fprintf
(
stderr
,
"_NXGetFontPath: Using default font path [%s].
\n
"
,
_NXFontPath
);
fprintf
(
stderr
,
"_NXGetFontPath: Using default font path [%s].
\n
"
,
_NXFontPath
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment