summaryrefslogtreecommitdiffstats
path: root/src/sss_client/nss_services.c
diff options
context:
space:
mode:
authorMichal Zidek <mzidek@redhat.com>2013-08-21 17:17:06 +0200
committerJakub Hrozek <jhrozek@redhat.com>2013-12-03 14:41:15 +0100
commita171d77f40aa92e240e91aa4bafe5a392a98b5a2 (patch)
tree67af7f48c89fbc1e7daa56c1d0c423cc0e19af74 /src/sss_client/nss_services.c
parentcebdc563a094d305b91da5b5af4d95d8e3a1bf27 (diff)
downloadsssd-a171d77f40aa92e240e91aa4bafe5a392a98b5a2.tar.gz
sssd-a171d77f40aa92e240e91aa4bafe5a392a98b5a2.tar.xz
sssd-a171d77f40aa92e240e91aa4bafe5a392a98b5a2.zip
sss_client: Use SAFEALIGN_COPY_<type> macros where appropriate.
resolves: https://fedorahosted.org/sssd/ticket/1359
Diffstat (limited to 'src/sss_client/nss_services.c')
-rw-r--r--src/sss_client/nss_services.c23
1 files changed, 17 insertions, 6 deletions
diff --git a/src/sss_client/nss_services.c b/src/sss_client/nss_services.c
index 5f98d8dc9..b40e1fa94 100644
--- a/src/sss_client/nss_services.c
+++ b/src/sss_client/nss_services.c
@@ -175,6 +175,7 @@ _nss_sss_getservbyname_r(const char *name,
uint8_t *repbuf;
uint8_t *data;
size_t replen, len;
+ uint32_t num_results;
enum nss_status nret;
int ret;
@@ -225,15 +226,18 @@ _nss_sss_getservbyname_r(const char *name,
svcrep.buffer = buffer;
svcrep.buflen = buflen;
+ /* Get number of results from repbuf. */
+ SAFEALIGN_COPY_UINT32(&num_results, repbuf, NULL);
+
/* no results if not found */
- if (((uint32_t *)repbuf)[0] == 0) {
+ if (num_results == 0) {
free(repbuf);
nret = NSS_STATUS_NOTFOUND;
goto out;
}
/* only 1 result is accepted for this function */
- if (((uint32_t *)repbuf)[0] != 1) {
+ if (num_results != 1) {
*errnop = EBADMSG;
free(repbuf);
nret = NSS_STATUS_TRYAGAIN;
@@ -272,6 +276,7 @@ _nss_sss_getservbyport_r(int port, const char *protocol,
uint8_t *data;
size_t p = 0;
size_t replen, len;
+ uint32_t num_results;
enum nss_status nret;
int ret;
@@ -320,15 +325,18 @@ _nss_sss_getservbyport_r(int port, const char *protocol,
svcrep.buffer = buffer;
svcrep.buflen = buflen;
+ /* Get number of results from repbuf. */
+ SAFEALIGN_COPY_UINT32(&num_results, repbuf, NULL);
+
/* no results if not found */
- if (((uint32_t *)repbuf)[0] == 0) {
+ if (num_results == 0) {
free(repbuf);
nret = NSS_STATUS_NOTFOUND;
goto out;
}
/* only 1 result is accepted for this function */
- if (((uint32_t *)repbuf)[0] != 1) {
+ if (num_results != 1) {
*errnop = EBADMSG;
free(repbuf);
nret = NSS_STATUS_TRYAGAIN;
@@ -400,6 +408,7 @@ static enum nss_status internal_getservent_r(struct servent *result,
struct sss_nss_svc_rep pwrep;
uint8_t *repbuf;
size_t replen;
+ uint32_t num_results;
enum nss_status nret;
uint32_t num_entries;
int ret;
@@ -444,9 +453,11 @@ static enum nss_status internal_getservent_r(struct servent *result,
return nret;
}
+ /* Get number of results from repbuf */
+ SAFEALIGN_COPY_UINT32(&num_results, repbuf, NULL);
+
/* no results if not found */
- if ((((uint32_t *)repbuf)[0] == 0)
- || (replen - SVC_METADATA_COUNT == 0)) {
+ if ((num_results == 0) || (replen - SVC_METADATA_COUNT == 0)) {
free(repbuf);
return NSS_STATUS_NOTFOUND;
}