Sometimes vnodepath is set to a local buffer. Sometimes it is set
to malloc'ed storage. Simplify the logic for freeing vnodepath
by checking explicitly for this condition rather than the state
of other variables. As a bonus, avoids a false (?) positive from
the static analyzer.
Change-Id: I3772cb97698acc5a6ac1f438977c673e6fea7722
Reviewed-on: http://gerrit.openafs.org/7869
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Simon Wilkinson <simonxwilkinson@gmail.com>
Reviewed-by: Alistair Ferguson <alistair.ferguson@mac.com>
Reviewed-by: Derrick Brashear <shadow@dementix.org>
Use the hostaddress (IpMappedAddr) table when looking up hosts by IP
address and when listing addresses by index, instead of accessing
the multi-homed extensions directly.
The existing vos client calls the old GetAddrs rpc to first retrieve
a count of the number of addresses expected. This count is the
number of addresses in the hostaddress table. If there are
unreferenced entries in the mh extension blocks, then vos can return
an incorrect or incomplete list of addresses.
To be consistent with the rest of the host address processing, use
the hostaddress table in GetAddrsU to lookup hosts by index or by IP
address.
The hostaddress table is already used when looking up addresses by
UUID.
Change-Id: I01aa29ae7d24d48bcd245f0320e329435f61548e
Reviewed-on: http://gerrit.openafs.org/7878
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Alistair Ferguson <alistair.ferguson@mac.com>
Reviewed-by: Derrick Brashear <shadow@dementix.org>
release_conns_vector must never have been called before with
a non-null parameter, because it could not possibly work.
The first line of the loop is a null pointer dereference, and
if that were fixed, there's also a modify-after-free bug as well.
It's not clear how what the old version was trying to do; this
version makes a stab at doing something sensible but might be
less than required. (Note that this would be much simpler if
converted to queue(3) macros or a similar standard linked-list
data structure.)
Change-Id: I4c0fb7ed1ee977dcc0b4dfb32557882679069731
Reviewed-on: http://gerrit.openafs.org/7838
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Alistair Ferguson <alistair.ferguson@mac.com>
Reviewed-by: Derrick Brashear <shadow@dementix.org>
Annotate ka_CellToRealm with AFS_NONNULL to indicate that its
"realm" parameter cannot be null; it does not make sense to call
this routine without this parameter. (The static analyzer inlines
the call to ka_ExpandCell and concludes that "realm" might be null;
the annotation will prevent that and avoid a false positive.)
Change-Id: Id7fac19cf4eb4bdb1decde81d951b8bcd96fce71
Reviewed-on: http://gerrit.openafs.org/7865
Reviewed-by: Derrick Brashear <shadow@dementix.org>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
We need MT_LIBS for -lpthread and such. HP-UX needs this, and probably
other platforms; otherwise we complain about missing pthreads symbols.
Change-Id: If7486cabfc20ef4238087f0285c25d9f8602703a
Reviewed-on: http://gerrit.openafs.org/7880
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Tested-by: Andrew Deason <adeason@sinenomine.net>
Reviewed-by: Derrick Brashear <shadow@dementix.org>
A few pieces of heimdal we use in the kernel call strcasecmp
(hcrypto/evp.c, krb5/crypto.c). The strcasecmp function does not exist
in all kernels (specifically, it does not exist in at least Linux 2.4,
2.6.9, and probably not on Solaris pre-10). Since we have our own copy
of strcasecmp (called afs_strcasecmp), just use that for now.
Ideally we would have some kind of configure test for detecting the
presence of the function in the kernel, and use the roken
implementation when we don't. We currently have the framework for
neither of those in place at the moment, though, so just get by with
this for now.
Change-Id: Ia96b17596da6cb168c80c92486fa049c05205da4
Reviewed-on: http://gerrit.openafs.org/7881
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Michael Meffie <mmeffie@sinenomine.net>
Tested-by: Michael Meffie <mmeffie@sinenomine.net>
Reviewed-by: Derrick Brashear <shadow@dementix.org>
We do not modify our args, so declare them const so we are usable with
const strings.
Change-Id: I2d60044014e51e2a52638b76ca50a5c2fc6980c0
Reviewed-on: http://gerrit.openafs.org/7882
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementix.org>
CreateIdList() is an internal subroutine of pr_IDListExpandedMembers(),
used to flatten a hash table of protection IDs into an array that can
be passed to pr_IdToName(). If for some reason the hash table had no
entries, it would call malloc(0) and, depending on how the
the implementation defines this, either return a PRNOMEM error (wrong!)
or else allocate a minimum-sized buffer which pr_IdListExpandedMembers
would then promptly leak. Compromise between the two behaviors by
not allocating any memory in this case but returning success, and in
the caller check for an empty list and avoid the pointless RPC to
translate no IDs into no names. pr_IDListExpandedMembers() will return
success, as it previously did in the non-PRNOMEM case.
Change-Id: I8a042bde3e98f5cf248358f37f2e875d6b5b298d
Reviewed-on: http://gerrit.openafs.org/7863
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Simon Wilkinson <simonxwilkinson@gmail.com>
Reviewed-by: Derrick Brashear <shadow@dementix.org>
This code was probably never executed, but now that lcstring() has
an AFS_NONNULL annotation, the static analyzer indicates the
potential null-pointer-dereference.
Change-Id: Idb41c2af1cb38bc5c084d4912614e0a553d4aa5a
Reviewed-on: http://gerrit.openafs.org/7864
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Simon Wilkinson <simonxwilkinson@gmail.com>
Reviewed-by: Derrick Brashear <shadow@dementix.org>
If cpp emitted
# 1234 ""
docppline() would leak a small buffer. Just free it.
The static analyzer will thank you.
Change-Id: I34ae6e228469a900139375f2a4758855922cf0ef
Reviewed-on: http://gerrit.openafs.org/7871
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Simon Wilkinson <simonxwilkinson@gmail.com>
Reviewed-by: Derrick Brashear <shadow@dementix.org>
Linux 2.4 does not have atomic_dec_return. If we switch to a
dec_and_test-like API, then we could use the Linux 2.4 atomics. But
for now, just raise the minimum to 2.6, and for 2.4 and below just use
the generic atomics implementation so we can build.
Change-Id: Ie584bd420839dbcbe3158fe7b50df633cb7eba6d
Reviewed-on: http://gerrit.openafs.org/7875
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementix.org>
The first two parameters of afs_ReadNoCache() are unconditionally
indirected through, and all existing callers appear to guarantee
that these parameters are in fact non-null, so annotate the function
declaration to so indicate, and remove the one test that checks
whether avc (the first parameter) is null. I suspect that acred
cannot be null either, but this code does not appear to depend on
that, so it's not included in the non-null annotation.
Change-Id: I496c868ffcbc9b894f91578019bc30bf7b14fefd
Reviewed-on: http://gerrit.openafs.org/7837
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Alistair Ferguson <alistair.ferguson@mac.com>
Reviewed-by: Derrick Brashear <shadow@dementix.org>
There's a typedef for this type, so use it in function prototypes
rather than the more complicated declarator.
Change-Id: I75a9b4e72201e6b2072dba14185579f9c4aa61be
Reviewed-on: http://gerrit.openafs.org/7858
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Alistair Ferguson <alistair.ferguson@mac.com>
Reviewed-by: Simon Wilkinson <simonxwilkinson@gmail.com>
Reviewed-by: Derrick Brashear <shadow@dementix.org>
Now that we have background probes, use them for VLDB server probes.
Change-Id: Ib160ec5ae702065f410e85ae949ae13a02c425e8
Reviewed-on: http://gerrit.openafs.org/7854
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Tested-by: Jeffrey Altman <jaltman@your-file-system.com>
It is important that down servers be detected as soon as possible.
When it is not possible to perform a blocking probe, perform a
probe in a backgrond thread.
Change-Id: If73856359ba894c5c302c11fd50aaa76cd2fcf28
Reviewed-on: http://gerrit.openafs.org/7853
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Tested-by: Jeffrey Altman <jaltman@your-file-system.com>
If the prserver returns an empty response to ubik_PR_NameToID
or ubik_PR_IDToName, but doesn't otherwise give an error,
force a PRINTERNAL error return so that the client knows that the
the return parameter was not updated. Existing callers seem to
expect this, as pr_SNameToId is often called without initializing
the variable which receives the result and checking only for the
error code.
PRINTERNAL is a new error code.
Change-Id: I3e598a22deb39792a0f208ac09b3c1991d6f1e58
Reviewed-on: http://gerrit.openafs.org/7836
Reviewed-by: Derrick Brashear <shadow@dementix.org>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Do not use the _strdup() C RTL function. Use strdup() so that
rk_strdup() roken replacement can be used.
Change-Id: Ifd2808a078b514468aee52ef76a9b51e606a2c88
Reviewed-on: http://gerrit.openafs.org/7848
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Tested-by: Jeffrey Altman <jaltman@your-file-system.com>
Make the ptclient utility build again, and add it to the ptserver
Makefile so that it is built by default and, hopefully, won't
bitrot again.
Change-Id: I888a9d4392b62ecb2d7556694400a2853658052a
Reviewed-on: http://gerrit.openafs.org/7841
Reviewed-by: Derrick Brashear <shadow@dementix.org>
Tested-by: Derrick Brashear <shadow@dementix.org>
If GetTokenEx is called with a NULL cellName, it means use the
local cell. To do this with the legacy interface, a 0 length string
must be used for the cell instance of the ktc_principal passed to
GetToken. Fix this so that we do so, rather than attempting to
strcpy(..., NULL) which never ends well.
Caught by clang-analyzer
Change-Id: I53d9bdf0fc280ee073a2fb7693659269df29c2eb
Reviewed-on: http://gerrit.openafs.org/7840
Reviewed-by: Derrick Brashear <shadow@dementix.org>
Tested-by: Derrick Brashear <shadow@dementix.org>
When queue_Scan is executed on an empty queue the queue element
variable, in this case 'rpc_stat' is the queue head, _RXQ(q),
and not NULL. Callers of rxi_FindRpcStat() expect NULL on failure
to find or create an rx_interface_stat object. Correct the behavior
by testing for an empty queue and return NULL immediately if the
queue is empty and the caller is not requesting creation.
Change-Id: I9952d7aaf357e039e87f6b8b17cb1a00208d6465
Reviewed-on: http://gerrit.openafs.org/7835
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Tidy up the way that we do system calls from afsd, by making
afsd_syscall a va_arg function, using a structure to pass system call
information around, and simplifying the #ifdef ladder that converts our
platform independent system calls into something platform specific.
This fixes all of the warnings in afsd which required the -Wno-error
option, the only warnings remaining are related to daemon being
deprecated on Darwin.
Change-Id: I357c7d175b5327007d50d213c6181881c842050e
Reviewed-on: http://gerrit.openafs.org/7188
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Tested-by: Derrick Brashear <shadow@dementix.org>
Reviewed-by: Derrick Brashear <shadow@dementix.org>
When calling cm_UpdateVolumeLocation the volp->mx must be held.
cm_Analyze() did not obtain the mutex as required.
Change-Id: Ida69105879a78692a367cd4439bee8e4bea751ff
Reviewed-on: http://gerrit.openafs.org/7839
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Tested-by: Jeffrey Altman <jaltman@your-file-system.com>
Set the correct bit after the bitmap is expanded with VGrowBitmap
so we don't allocate it twice and trigger a salvage.
Change-Id: Iee307a0913d4402c2d5a32d493ff489b35778811
Reviewed-on: http://gerrit.openafs.org/7793
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementix.org>
There's no need for type-punning here; usr_getspecific() is a macro
that just assigns to the variable whose address we provide, so the
cast was just unnecessary (and erroneous) obfuscation. This is the
only caller of usr_getspecific(), so if it needs to be more complex
in the future, it should probably just be open-coded here.
Change-Id: I81286cbce9a00908aa87073b728b07d8bcc8d1d1
Reviewed-on: http://gerrit.openafs.org/7799
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementix.org>
in this case, racing another ClientInit caller is not fatal.
clean up from 56b5b9a1c51c2197923aa373c180a834edabe4f6 which was
my fault.
Change-Id: I81d3298a775ed46972779b4121498560883fee01
Reviewed-on: http://gerrit.openafs.org/7803
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Garrett Wollman <wollman@csail.mit.edu>
Reviewed-by: Derrick Brashear <shadow@dementix.org>
The C standard allows NULL to be defined as a bare "0", which will
be passed to variadic functions as an int. If the function expects
a pointer type, demons fly out of your nose. strcompose() is such
a function, so make sure that all of its callers cast NULL appropriately.
(None of them did.) This may be an opportune time to change all of
the callers to spell it opr_strcompose() as well, and avoid using a
reserved identifier, but this change does not do so.
Change-Id: Ia9007a48102da4d0a85a48b41a44e83102304b49
Reviewed-on: http://gerrit.openafs.org/7805
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementix.org>
All of these string functions require at least one non-null argument.
Mark them as AFS_NONNULL() so that the compiler and static checker can
find erroneous uses. The "source" arguments of lcstring and ucstring
can be const, so do so. (This doesn't affect anything in the tree
right now.) While here, note a few unfixed issues with these interfaces.)
Change-Id: If2a8dd4d617795560e92c09ee604780f90edce6a
Reviewed-on: http://gerrit.openafs.org/7804
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementix.org>
on macos, VDIR is not useful as part of a directory mode. it's just not.
on aix, solaris, we presumably want to pass S_ISDIR, so do so
Change-Id: I04ee49857febf1cf96d30bd6a8271f99192630c8
Reviewed-on: http://gerrit.openafs.org/7789
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementix.org>
After VL_ProbeServer and RXAFS_Getcapabilities RPCs call
cm_RankServer() to recompute the server ranks based upon the
updated peer statistics.
Change-Id: I84687e12f1c1bd323a95c5ffcc73b95d400bd1f5
Reviewed-on: http://gerrit.openafs.org/7827
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementix.org>
When an IP address change has been detected, clear the peer
RPC statistics used for server ranking.
Change-Id: Ie9e3f4553f9d0b22d4876b729ce0028e762efb33
Reviewed-on: http://gerrit.openafs.org/7826
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementix.org>
Use VL_ProbeServer for VLDB servers and either
opcode_RXAFS_GetCapabilities or opcode_RXAFS_GetTime for
File servers.
Change-Id: I67c3ad88ac3dd07ac1c0e44d462853d068bf50c8
Reviewed-on: http://gerrit.openafs.org/7825
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementix.org>
define an opcode-name-specific define with the numeric value
of the opcode
Change-Id: I34e6eb57ac2c57319a83b0279cc9115050a39c4f
Reviewed-on: http://gerrit.openafs.org/7801
Reviewed-by: Jacob Thebault-Spieker <summatusmentis@gmail.com>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Derrick Brashear <shadow@dementix.org>
It's implementation-defined whether the C '>>' operator, when
applied to a signed integer, is sign-extending or zero-filling.
If you want unsigned arithmetic, you have to ask for it explicitly.
One assumes the reason for the shift is to avoid overflow if the
returned size/count is later converted to a signed int, in which
case maybe it would be better to use INT_MAX here. This is the
minimal change necessary for correctness.
Change-Id: I6e848110963b5e1832a11d052d84884f10903e2e
Reviewed-on: http://gerrit.openafs.org/7800
Reviewed-by: Derrick Brashear <shadow@dementix.org>
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
If there are extents in the list with a non-zero ActiveCount,
those extents will be skipped and the list 'le' will never
become empty. Add an additional condition to ensure that the
loop is only executed once for each extent in the list.
Change-Id: I48adf7c49282181d0a34135ac50f7fa1a165c735
Reviewed-on: http://gerrit.openafs.org/7810
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Tested-by: Jeffrey Altman <jaltman@your-file-system.com>
In an error occurs during AFSInitPIOCtlDirectoryCB processing
the nonpaged pool allocation would be leaked.
Change-Id: I092538202d84bd65476ba21a68e210d5f626ead2
Reviewed-on: http://gerrit.openafs.org/7809
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Tested-by: Jeffrey Altman <jaltman@your-file-system.com>
Replace AFSExFreePool() with AFSExFreePoolWithTag() which is
a wrapper around both ExFreePool() and ExFreePoolWithTag().
If a 'Tag' value, is provided, ExFreePoolWithTag() is used.
Otherwise, ExFreePool().
Specify allocation tag values wherever possible. Path name buffer
tags are not specified because they are allocated using multiple
tags. The same is true for network provider string buffers.
This is being done in order to debug a memory corruption issue.
Warning: this is a change to the AFSRedir->AFSRedirLib interface
and therefore both drivers must be updated with a reboot and
not simply restarting the service.
Change-Id: Id5c0503141d1077d6c2beae5d28602160105a312
Reviewed-on: http://gerrit.openafs.org/7807
Tested-by: BuildBot <buildbot@rampaginggeek.com>
Reviewed-by: Jeffrey Altman <jaltman@your-file-system.com>
Tested-by: Jeffrey Altman <jaltman@your-file-system.com>