Ethereal-dev: [Ethereal-dev] [Patch] asn1 plugin
Note: This archive is from the project's previous web site, ethereal.com. This list is no longer active.
From: "Gisle Vanem" <giva@xxxxxxxxx>
Date: Sun, 2 Nov 2003 14:12:28 +0100
* Added a new function get_file_in_temp() to epan/filesystem.c. This because of asn1.dll plugin which had code to write to a log-file "c:\temp\ethereal.log". I feel this patch makes this safer; I don't even have a c:\temp dir. * Patched packet-asn1.c to use get_file_in_temp(). * Added some #undef to packet-snmp.c to silence gcc. * Changed "%u" -> "%lu" formats in util.c Note: I used the ignore whitespace option (-w) to GNU diff because there's so many files with *trailing* whitespace. My diff actually includes some changes in *leading* whitespace, but you'll figure it out. We should IMHO strip trailing WS before checking them in. Gisle V.
diff -u3 -H -B -w -r ethereal-2003-11-01\epan\filesystem.c .\epan\filesystem.c --- ethereal-2003-11-01\epan\filesystem.c Mon Sep 15 20:04:59 2003 +++ .\epan\filesystem.c Sat Nov 01 23:12:51 2003 @@ -627,3 +627,26 @@ { return unlink(path) == 0; } + +/* + * Construct and return the path name of a file in the + * $TMP/%TEMP% directory. + */ +char *get_file_in_temp(const char *file) +{ + char path [PATH_MAX], *dir, *def; + +#ifdef WIN32 + dir = getenv("TEMP"); + def = "C:\\"; +#else + dir = getenv("TMP"); + def = "/tmp"; +#endif + if (!dir || (dir = get_dirname(dir)) == NULL) + return g_strdup(def); + + snprintf(path, sizeof(path), "%s%c%s", dir, G_DIR_SEPARATOR, file); + return g_strdup(path); +} + diff -u3 -H -B -w -r ethereal-2003-11-01\epan\filesystem.h .\epan\filesystem.h --- ethereal-2003-11-01\epan\filesystem.h Thu May 15 08:44:54 2003 +++ .\epan\filesystem.h Sat Nov 01 23:06:31 2003 @@ -111,6 +111,15 @@ */ char *get_persconffile_path(const char *filename, gboolean for_writing); +/* + * Construct the path name of a file in $TMP/%TEMP% directory. + * Or "/tmp/<filename>" (C:\<filename>) if that fails. + * + * Return value is malloced so the caller should free it. + */ +char *get_file_in_temp(const char *filename); + + /* Delete a file */ gboolean deletefile (const char *path); #endif /* FILESYSTEM_H */ diff -u3 -H -B -w -r ethereal-2003-11-01\plugins\asn1\packet-asn1.c .\plugins\asn1\packet-asn1.c --- ethereal-2003-11-01\plugins\asn1\packet-asn1.c Thu Oct 30 12:56:36 2003 +++ .\plugins\asn1\packet-asn1.c Sat Nov 01 23:01:56 2003 @@ -145,12 +145,9 @@ static gboolean asn1_verbose = FALSE; /* change to TRUE for logging the startup phase */ static gboolean asn1_full = FALSE; /* show full names */ static guint type_recursion_level = 1; /* eliminate 1 level of references */ -static char *asn1_logfile = 0; -#ifdef WIN32 -#define ASN1LOGFILE "C:\\temp\\ethereal.log" -#else -#define ASN1LOGFILE "/tmp/ethereal.log" -#endif +static char *asn1_logfile = NULL; + +#define ASN1LOGFILE "ethereal.log" /* PDU counter, for correlation between GUI display and log file in debug mode */ static int pcount = 0; @@ -2563,12 +2560,14 @@ (void) log_domain; (void) log_level; (void) user_data; /* make references */ - if (logf == 0) { + if (logf == NULL && asn1_logfile) { logf = fopen(asn1_logfile, "w"); } + if (logf) { fputs(message, logf); fputs(eol, logf); } +} void read_asn1_type_table(char *filename) @@ -3332,7 +3331,7 @@ #ifdef DISSECTOR_WITH_GUI /* This cannot work in tethereal.... don't include for now */ #if GTK_MAJOR_VERSION >= 2 -#define SHOWPDU /* this needs GTK2, which is not yet on Win32 .............. */ +#define SHOWPDU /* this needs GTK2 */ #endif #endif /* DISSECTOR_WITH_GUI */ #ifdef SHOWPDU @@ -4638,8 +4637,7 @@ module_t *asn1_module; int i, j; - - asn1_logfile = g_strdup(ASN1LOGFILE); + asn1_logfile = get_file_in_temp(ASN1LOGFILE); current_pduname = g_strdup("ASN1"); asn1_pduname = g_strdup(current_pduname); @@ -4712,7 +4710,7 @@ &asn1_message_win); prefs_register_bool_preference(asn1_module, "verbose_log", "Write very verbose log", - "log to file " ASN1LOGFILE, + "log to file $TMP/" ASN1LOGFILE, &asn1_verbose); } diff -u3 -H -B -w -r ethereal-2003-11-01\plugins\plugin_api_list.c .\plugins\plugin_api_list.c --- ethereal-2003-11-01\plugins\plugin_api_list.c Sat Nov 01 04:10:03 2003 +++ .\plugins\plugin_api_list.c Sun Nov 02 00:16:16 2003 @@ -379,6 +379,7 @@ dissector_handle_t dissector_get_string_handle(dissector_table_t, const gchar*); char *get_datafile_path(const char *filename); +char *get_file_in_temp(const char *filename); void register_heur_dissector_list(const char *name, heur_dissector_list_t *list); diff -u3 -H -B -w -r ethereal-2003-11-01\packet-snmp.c .\packet-snmp.c --- ethereal-2003-11-01\packet-snmp.c Wed Oct 29 23:11:08 2003 +++ packet-snmp.c Sun Nov 02 13:30:43 2003 @@ -182,6 +182,20 @@ { 0, NULL }, }; +/* defined in net-SNMP; include/net-snmp/library/snmp.h */ +#undef SNMP_MSG_GET +#undef SNMP_MSG_SET +#undef SNMP_MSG_GETNEXT +#undef SNMP_MSG_RESPONSE +#undef SNMP_MSG_TRAP +#undef SNMP_MSG_GETBULK +#undef SNMP_MSG_INFORM +#undef SNMP_MSG_TRAP2 +#undef SNMP_MSG_REPORT +#undef SNMP_NOSUCHOBJECT +#undef SNMP_NOSUCHINSTANCE +#undef SNMP_ENDOFMIBVIEW + /* PDU types */ #define SNMP_MSG_GET 0 #define SNMP_MSG_GETNEXT 1 diff -u3 -H -B -w -r ethereal-2003-11-01\util.c util.c --- ethereal-2003-11-01\util.c Fri Oct 31 08:57:22 2003 +++ util.c Sun Nov 02 13:29:33 2003 @@ -237,14 +237,14 @@ break; default: - g_string_sprintfa(str, "Windows OT, unknown version %u.%u", + g_string_sprintfa(str, "Windows OT, unknown version %lu.%lu", info.dwMajorVersion, info.dwMinorVersion); break; } break; default: - g_string_sprintfa(str, "Windows OT, unknown version %u.%u", + g_string_sprintfa(str, "Windows OT, unknown version %lu.%lu", info.dwMajorVersion, info.dwMinorVersion); break; } @@ -256,7 +256,7 @@ case 3: case 4: - g_string_sprintfa(str, "Windows NT %u.%u", + g_string_sprintfa(str, "Windows NT %lu.%lu", info.dwMajorVersion, info.dwMinorVersion); break; @@ -277,27 +277,27 @@ break; default: - g_string_sprintfa(str, "Windows NT, unknown version %u.%u", + g_string_sprintfa(str, "Windows NT, unknown version %lu.%lu", info.dwMajorVersion, info.dwMinorVersion); break; } break; default: - g_string_sprintfa(str, "Windows NT, unknown version %u.%u", + g_string_sprintfa(str, "Windows NT, unknown version %lu.%lu", info.dwMajorVersion, info.dwMinorVersion); break; } break; default: - g_string_sprintfa(str, "Unknown Windows platform %u version %u.%u", + g_string_sprintfa(str, "Unknown Windows platform %lu version %lu.%lu", info.dwPlatformId, info.dwMajorVersion, info.dwMinorVersion); break; } if (info.szCSDVersion[0] != '\0') g_string_sprintfa(str, " %s", info.szCSDVersion); - g_string_sprintfa(str, ", build %u", info.dwBuildNumber); + g_string_sprintfa(str, ", build %lu", info.dwBuildNumber); #elif defined(HAVE_SYS_UTSNAME_H) /* * We have <sys/utsname.h>, so we assume we have "uname()".
- Follow-Ups:
- Re: [Ethereal-dev] [Patch] asn1 plugin
- From: Gerald Combs
- Re: [Ethereal-dev] [Patch] asn1 plugin
- From: Guy Harris
- Re: [Ethereal-dev] [Patch] asn1 plugin
- Prev by Date: Re: [Ethereal-dev] Patch for Linux Capabilities
- Next by Date: [Ethereal-dev] Enhancement patch for GSM A-i/f
- Previous by thread: Re: [Ethereal-dev] Patch for Linux Capabilities
- Next by thread: Re: [Ethereal-dev] [Patch] asn1 plugin
- Index(es):