aboutsummaryrefslogtreecommitdiffstats
path: root/wsutil/tempfile.c
AgeCommit message (Collapse)AuthorFilesLines
2023-09-24Convert wsutil to C99 typesGerald Combs1-10/+10
Ping #19116
2023-06-24Make wsutil headers include what they use and build standaloneNicolás Alvarez1-1/+1
There's many wsutil headers which used glib types like guint8 or GString but didn't include glib.h. If a new .c file included wsutil/xx.h, it would not compile if it doesn't include glib.h first. This commit adds #include <wireshark.h> to the headers in wsutil where GLib types are being used. It also makes every wsutil/xx.c file include the corresponding xx.h before including anything else, which makes the build fail if the header doesn't build standalone due to missing other includes.
2022-12-12Extcap: Create our fifo in a temporary directory.Gerald Combs1-16/+48
Instead of creating a temp file, unlinking it, and creating a fifo with the same name, add create_tempdir() so that we can create a temporary directory and create a fifo inside that. This should avoid a race condition in Carbon Black Cloud antivirus, which if the timing is right, will stat the initial temporary *file*, miss the fact that it's been replaced with a *fifo*, and open and steal data^W^W read from it, leaving dumpcap to contend with the truncated remains. Adding the unexpected magic number to cap_pipe_open_live()'s error message helped to debug this. Leave it in since it's handy to have in that case. Ping #15587
2022-02-09Specify directory for temporary capturesDavid Perry1-5/+59
2021-12-19wsutil: Use snprintf() and ws_strdup_printf()João Valverde1-3/+1
Replace GLib I/O with C library I/O.
2021-04-14Fix -Wdocumentation warningAlexis La Goutte1-1/+1
2020-01-06wsutil: Replace disallowed filename characters to '-'Stig Bjørlykke1-1/+18
Revert the removal of replacing disallowed filename characters in create_tempfile() to allow this characters in extcap interface names. This is a regression from g2925fb08. Change-Id: I833d1d19080c9c688dcaf076a840f55ef31e457d Reviewed-on: https://code.wireshark.org/review/35669 Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org> Petri-Dish: Stig Bjørlykke <stig@bjorlykke.org> Tested-by: Petri Dish Buildbot Reviewed-by: Guy Harris <guy@alum.mit.edu>
2019-12-20Use g_file_open_tmp within create_tempfileMichael Mann1-152/+12
Much better to use a known library than create it ourselves. Also remove get_tempfile_path as it's not used. Bug: 15992 Change-Id: I17b9bd879e8bdb540f79db83c6c138f8ee724764 Reviewed-on: https://code.wireshark.org/review/34420 Reviewed-by: Tomasz Moń <desowin@gmail.com> Petri-Dish: Tomasz Moń <desowin@gmail.com> Tested-by: Petri Dish Buildbot Reviewed-by: Roland Knall <rknall@gmail.com>
2019-10-30Fix the temporary file string buffer expansion.Guy Harris1-2/+4
The buffer needs to be big enough to include the trailing '\0', so we need to compare the buffer's length against strlen(name) + 1, not against strlen(name). Bug: 15751 Change-Id: I75ae65f8c818284834d761d9dd911d029cfca3b1 Reviewed-on: https://code.wireshark.org/review/34892 Petri-Dish: Guy Harris <guy@alum.mit.edu> Tested-by: Petri Dish Buildbot Reviewed-by: Guy Harris <guy@alum.mit.edu>
2019-07-27HTTPS In Still More Places, update more URLs.Guy Harris1-1/+1
Microsoft reshuffled their documentation - almost all of it moved from msdn.microsoft.com to docs.microsoft.com. Some blogs moved to devblogs.microsoft.com; the comments *didn't* move, so in one case we go to the Wayback Machine - the link isn't dead, but it formats horribly, at least on my browser, but the archived version formats OK. Use the Wayback Machine for some URLs, and update others. Update the sections for MS-ADTS. Point to the HTML versions of some RFCs and I-Ds. Change-Id: I344b20f880de63f1ae2a4e3f9ff98af78a7fe139 Reviewed-on: https://code.wireshark.org/review/34101 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2019-07-26HTTPS (almost) everywhere.Guy Harris1-1/+1
Change all wireshark.org URLs to use https. Fix some broken links while we're at it. Change-Id: I161bf8eeca43b8027605acea666032da86f5ea1c Reviewed-on: https://code.wireshark.org/review/34089 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2018-03-12Remove some unused or hard-coded header checks.Gerald Combs1-87/+0
Remove some unused checks and code found using grep -o 'HAVE_[A-Z0-9_]*' ConfigureChecks.cmake | sort -u \ | while read have_h ; do echo = $have_h ; git --no-pager grep -cl $have_h ; done Change-Id: I86bfcfdc4f60d9d7de87017a7bb00f833a79bd2c Reviewed-on: https://code.wireshark.org/review/26451 Petri-Dish: Gerald Combs <gerald@wireshark.org> Tested-by: Petri Dish Buildbot Reviewed-by: Gerald Combs <gerald@wireshark.org>
2018-02-08replace SPDX identifier GPL-2.0+ with GPL-2.0-or-later.Dario Lombardo1-1/+1
The first is deprecated, as per https://spdx.org/licenses/. Change-Id: I8e21e1d32d09b8b94b93a2dc9fbdde5ffeba6bed Reviewed-on: https://code.wireshark.org/review/25661 Petri-Dish: Anders Broman <a.broman58@gmail.com> Petri-Dish: Dario Lombardo <lomato@gmail.com> Reviewed-by: Anders Broman <a.broman58@gmail.com>
2017-12-10Convert to using use SPDX identifier on wsutil directoryMichael Mann1-13/+1
Change-Id: Id73e641499e75bc1afc1dea29682418156f461fe Reviewed-on: https://code.wireshark.org/review/24751 Petri-Dish: Michael Mann <mmann78@netscape.net> Tested-by: Petri Dish Buildbot Reviewed-by: Michael Mann <mmann78@netscape.net>
2017-10-26CMake: Don't check for windows.h or winsock2.h.Gerald Combs1-4/+1
If we're building on Windows we're going to have windows.h and winsock2.h. Don't bother checking for them. Change-Id: I0004c44d7364ab3f41682f34b8c84cd8617c9603 Reviewed-on: https://code.wireshark.org/review/24068 Reviewed-by: Gerald Combs <gerald@wireshark.org> Petri-Dish: Gerald Combs <gerald@wireshark.org> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
2017-04-18Check the result of localtime().Guy Harris1-2/+6
Unlikely to fail, but it squelches CID 1398220. Change-Id: I0e40146f0a32c1082e84052c6b3e382fe6a15ae7 Reviewed-on: https://code.wireshark.org/review/21177 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-10-22More checks for localtime() and gmtime() returning NULL.Guy Harris1-0/+1
And some comments in the case where we're converting the result of time() - if your machine's idea of time predates January 1, 1970, 00:00:00 UTC, it'll crash on Windows, but that's not a case where a *file* can cause the problem due either to a bad file time stamp or bad time stamps in the file. Change-Id: I837a438e4b875dd8c4f3ec2137df7a16ee4e9498 Reviewed-on: https://code.wireshark.org/review/18369 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2016-06-01Fix compile error:Joerg Mayer1-1/+1
[ 0%] Building C object wsutil/CMakeFiles/wsutil.dir/tempfile.c.o /Users/jmayer/worktmp/wireshark/git/wsutil/tempfile.c:228:37: error: implicit conversion loses integer precision: 'unsigned long' to 'int' [-Werror,-Wshorten-64-to-32] fd = mkstemps(tf[idx].path, sfx ? strlen(sfx) : 0); ~~~~~~~~ ^~~~~~~~~~~ 1 error generated. No idea whether this is the correct fix. Change-Id: I80202d7eaad11fc3dcb5f9847f6e162caccb7e6e Reviewed-on: https://code.wireshark.org/review/15672 Reviewed-by: Jörg Mayer <jmayer@loplof.de>
2016-06-01Allow create_tempfile to support a suffix.Michael Mann1-16/+19
Ping-Bug: 10203 Change-Id: Ifa24870d711449b87e9839dd46af614e4aa28fde Reviewed-on: https://code.wireshark.org/review/15608 Petri-Dish: Michael Mann <mmann78@netscape.net> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Martin Mathieson <martin.r.mathieson@googlemail.com>
2016-04-13Windows: Remove the need for _CRT_NONSTDC_NO_DEPRECATE.Gerald Combs1-4/+4
Replace some function calls with their non-deprecated equivalents so that we can remove _CRT_NONSTDC_NO_DEPRECATE from CMakeLists.txt and config.nmake. Leave _CRT_SECURE_NO_DEPRECATE in place. Removing it failed with 145 warnings and 72 errors. Note that we could probably improve startup performance by using wmem in diam_dict.*. Change-Id: I6e130003de838aebedbdd1aa78c50de8a339ddcb Reviewed-on: https://code.wireshark.org/review/14883 Reviewed-by: Gerald Combs <gerald@wireshark.org> Petri-Dish: Gerald Combs <gerald@wireshark.org> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Michael Mann <mmann78@netscape.net>
2015-11-07Clean up includes of unistd.h, fcntl.h, and sys/stat.h.Guy Harris1-8/+0
Have wsutil/file_util.h include them on UN*X, just as it includes io.h on Windows, so we can have a rule of "if you do file operations, include <wsutil/file_util.h> and use the routines in it". Remove includes of unistd.h, fcntl.h, and sys/stat.h that aren't necessary (whether because of the addition of them to wsutil/file_util.h or because they weren't needed in the first place). Change-Id: Ie241dd74deff284e39a5f690a297dbb6e1dc485f Reviewed-on: https://code.wireshark.org/review/11619 Petri-Dish: Guy Harris <guy@alum.mit.edu> Reviewed-by: Guy Harris <guy@alum.mit.edu>
2015-05-09Rename a variable to avoid a collision with the C++ keyword "template".Guy Harris1-15/+15
Change-Id: I27c5efc5586e97d19ef905921919e1385809eb9b Reviewed-on: https://code.wireshark.org/review/8367 Reviewed-by: Guy Harris <guy@alum.mit.edu>
2014-12-28Add a couple of more needed includesMartin Mathieson1-1/+1
Change-Id: Ie160f81544c6c9b381078b555e91602617cb2700 Reviewed-on: https://code.wireshark.org/review/6101 Reviewed-by: Martin Mathieson <martin.r.mathieson@googlemail.com>
2014-12-28Deleting unnecessary #includes from wsutil.Martin Mathieson1-4/+0
Will look at cleaning up and committing script afterwards. Change-Id: Id785e581740ab62fe9258ecfcb0926761ad9c527 Reviewed-on: https://code.wireshark.org/review/6086 Reviewed-by: Martin Mathieson <martin.r.mathieson@googlemail.com>
2014-11-19[pedantic] Replace usage of 'long' and 'long long'Bill Meier1-2/+2
Change-Id: I78fc82c1a83eb04d78a11fc76710c92dfc916208 Reviewed-on: https://code.wireshark.org/review/5395 Reviewed-by: Bill Meier <wmeier@newsguy.com>
2014-10-14Add editor-modelines; adjust whitespace.Bill Meier1-99/+112
Change-Id: I8cad872cee972a6d22a72852dac57fd188daca84 Reviewed-on: https://code.wireshark.org/review/4683 Reviewed-by: Bill Meier <wmeier@newsguy.com>
2014-03-04Remove all $Id$ from top of fileAlexis La Goutte1-2/+0
(Using sed : sed -i '/^ \* \$Id\$/,+1 d') Fix manually some typo (in export_object_dicom.c and crc16-plain.c) Change-Id: I4c1ae68d1c4afeace8cb195b53c715cf9e1227a8 Reviewed-on: https://code.wireshark.org/review/497 Reviewed-by: Anders Broman <a.broman58@gmail.com>
2013-11-17Move get_tempfile_path() from filesystem.[ch] to tempfile.[ch].Guy Harris1-3/+9
svn path=/trunk/; revision=53379
2013-06-26Move tempfile.{h,c} into wsutil.Jeff Morriss1-0/+279
svn path=/trunk/; revision=50163