aboutsummaryrefslogtreecommitdiff
path: root/src/or/ntmain.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2012-01-11 14:02:59 -0500
committerNick Mathewson <nickm@torproject.org>2012-01-16 15:03:44 -0500
commit9c29369a04cdf47bd882579331577d82305bf785 (patch)
tree4a9752c89feb50c9fced1d18fdb4bbf24e3d9b72 /src/or/ntmain.c
parentcc02823d7f6acbc3fa8ea87e5646921100796f10 (diff)
downloadtor-9c29369a04cdf47bd882579331577d82305bf785.tar.gz
tor-9c29369a04cdf47bd882579331577d82305bf785.zip
Convert instances of tor_malloc+tor_snprintf into tor_asprintf
These were found by looking for tor_snprintf() instances that were preceeded closely by tor_malloc(), though I probably converted some more snprintfs as well. (In every case, make sure that the length variable (if any) is removed, renamed, or lowered, so that anything else that might have assumed a longer buffer doesn't exist.)
Diffstat (limited to 'src/or/ntmain.c')
-rw-r--r--src/or/ntmain.c20
1 files changed, 6 insertions, 14 deletions
diff --git a/src/or/ntmain.c b/src/or/ntmain.c
index 8d03ea8087..da19573a46 100644
--- a/src/or/ntmain.c
+++ b/src/or/ntmain.c
@@ -456,9 +456,9 @@ nt_service_command_line(int *using_default_torrc)
{
TCHAR tor_exe[MAX_PATH+1];
char tor_exe_ascii[MAX_PATH+1];
- char *command, *options=NULL;
+ char *command=NULL, *options=NULL;
smartlist_t *sl;
- int i, cmdlen;
+ int i;
*using_default_torrc = 1;
/* Get the location of tor.exe */
@@ -487,21 +487,13 @@ nt_service_command_line(int *using_default_torrc)
strlcpy(tor_exe_ascii, tor_exe, sizeof(tor_exe_ascii));
#endif
- /* Allocate a string for the NT service command line */
- cmdlen = strlen(tor_exe_ascii) + (options?strlen(options):0) + 32;
- command = tor_malloc(cmdlen);
-
+ /* Allocate a string for the NT service command line and */
/* Format the service command */
if (options) {
- if (tor_snprintf(command, cmdlen, "\"%s\" --nt-service \"%s\"",
- tor_exe_ascii, options)<0) {
- tor_free(command); /* sets command to NULL. */
- }
+ tor_asprintf(&command, "\"%s\" --nt-service \"%s\"",
+ tor_exe_ascii, options);
} else { /* ! options */
- if (tor_snprintf(command, cmdlen, "\"%s\" --nt-service",
- tor_exe_ascii)<0) {
- tor_free(command); /* sets command to NULL. */
- }
+ tor_asprintf(&command, "\"%s\" --nt-service", tor_exe_ascii);
}
tor_free(options);