Permalink
Browse files

Fixes EUCA-3962 where a string buffer may endup not null terminated.

Fixes Coverity issue #11096.
  • Loading branch information...
gelinasc committed Nov 21, 2012
1 parent e788d9e commit 2c03873b939b46a2dfca90b14ac5163b0399085e
View
@@ -65,39 +65,46 @@
#include <gl-client-marshal.h>
#include <euca_auth.h>
-int main(int argc, char **argv) {
- axutil_env_t * env = NULL;
- axis2_char_t * client_home = NULL;
- axis2_char_t endpoint_uri[256], *tmpstr;
- axis2_stub_t * stub = NULL;
- int rc, i;
- char *euca_home;
-
- snprintf(endpoint_uri, 256," http://%s/axis2/services/EucalyptusGL", argv[1]);
- // env = axutil_env_create_all("/tmp/GLclient.log", AXIS2_LOG_LEVEL_TRACE);
- env = axutil_env_create_all("/tmp/fooh", AXIS2_LOG_LEVEL_TRACE);
- client_home = AXIS2_GETENV("AXIS2C_HOME");
- if (!client_home) {
- printf("must have AXIS2C_HOME set\n");
- }
- stub = axis2_stub_create_EucalyptusGL(env, client_home, endpoint_uri);
+int main(int argc, char **argv)
+{
+ axutil_env_t *env = NULL;
+ axis2_char_t *client_home = NULL;
+ axis2_char_t endpoint_uri[256], *tmpstr;
+ axis2_stub_t *stub = NULL;
+ int rc, i;
+ char *euca_home;
- if (!strcmp(argv[2], "getLogs")) {
- char *clog, *nlog, *hlog, *alog;
- rc = gl_getLogs(argv[3], &clog, &nlog, &hlog, &alog, env, stub);
- if (!rc) {
- if (clog) printf("CLOG\n----------\n%s\n-----------\n", base64_dec((unsigned char *)clog, strlen(clog)));
- if (nlog) printf("NLOG\n----------\n%s\n-----------\n", base64_dec((unsigned char *)nlog, strlen(nlog)));
- if (hlog) printf("HLOG\n----------\n%s\n-----------\n", base64_dec((unsigned char *)hlog, strlen(hlog)));
- if (alog) printf("ALOG\n----------\n%s\n-----------\n", base64_dec((unsigned char *)alog, strlen(alog)));
- }
- } else if (!strcmp(argv[2], "getKeys")) {
- char *cccert, *nccert;
- rc = gl_getKeys(argv[3], &cccert, &nccert, env, stub);
- if (!rc) {
- if (cccert) printf("CCCERT\n----------\n%s\n-----------\n", base64_dec((unsigned char *)cccert, strlen(cccert)));
- if (nccert) printf("NCCERT\n----------\n%s\n-----------\n", base64_dec((unsigned char *)nccert, strlen(nccert)));
- }
- }
- exit(0);
+ snprintf(endpoint_uri, 256, " http://%s/axis2/services/EucalyptusGL", argv[1]);
+ // env = axutil_env_create_all("/tmp/GLclient.log", AXIS2_LOG_LEVEL_TRACE);
+ env = axutil_env_create_all("/tmp/fooh", AXIS2_LOG_LEVEL_TRACE);
+ client_home = AXIS2_GETENV("AXIS2C_HOME");
+ if (!client_home) {
+ printf("must have AXIS2C_HOME set\n");
+ }
+ stub = axis2_stub_create_EucalyptusGL(env, client_home, endpoint_uri);
+
+ if (!strcmp(argv[2], "getLogs")) {
+ char *clog, *nlog, *hlog, *alog;
+ rc = gl_getLogs(argv[3], &clog, &nlog, &hlog, &alog, env, stub);
+ if (!rc) {
+ if (clog)
+ printf("CLOG\n----------\n%s\n-----------\n", base64_dec((unsigned char *)clog, strlen(clog)));
+ if (nlog)
+ printf("NLOG\n----------\n%s\n-----------\n", base64_dec((unsigned char *)nlog, strlen(nlog)));
+ if (hlog)
+ printf("HLOG\n----------\n%s\n-----------\n", base64_dec((unsigned char *)hlog, strlen(hlog)));
+ if (alog)
+ printf("ALOG\n----------\n%s\n-----------\n", base64_dec((unsigned char *)alog, strlen(alog)));
+ }
+ } else if (!strcmp(argv[2], "getKeys")) {
+ char *cccert, *nccert;
+ rc = gl_getKeys(argv[3], &cccert, &nccert, env, stub);
+ if (!rc) {
+ if (cccert)
+ printf("CCCERT\n----------\n%s\n-----------\n", base64_dec((unsigned char *)cccert, strlen(cccert)));
+ if (nccert)
+ printf("NCCERT\n----------\n%s\n-----------\n", base64_dec((unsigned char *)nccert, strlen(nccert)));
+ }
+ }
+ exit(0);
}
View
@@ -121,6 +121,10 @@ deploy:
# no ws
$(INSTALL) $(DESTDIR)$(AXIS2C_SERVICES)/$(SERVICE_NAME)/services_noWS.xml $(DESTDIR)$(AXIS2C_SERVICES)/$(SERVICE_NAME)/services.xml
+indent:
+ @indent *.[ch] -nbad -bap -nbc -bbo -hnl -br -brs -c33 -cd33 -ncdb -ce -ci4 -cli0 -d0 -di1 -nfc1 -i4 -ut -ip0 -l200 -lp -npcs -nprs -npsl -sai -saf -saw -ncs -nsc -sob -nfca -ss -ts4 -il0 -nip
+ @\rm *.*~
+
clean:
rm -f $(SERVICE_SO) *.o $(CLIENT) *~* *#*
@@ -65,66 +65,68 @@
#include <gl-client-marshal.h>
#include <euca_auth.h>
-int gl_getLogs(char *service, char **outCClog, char **outNClog, char **outHlog, char **outAlog, axutil_env_t *env, axis2_stub_t *stub) {
- char *outservice;
-
- adb_GetLogsResponse_t *out;
- adb_getLogsResponseType_t *response;
-
- adb_GetLogs_t *in;
- adb_getLogsType_t *request;
-
- request = adb_getLogsType_create(env);
- adb_getLogsType_set_userId(request, env, "eucalyptus");
- adb_getLogsType_set_correlationId(request, env, "12345678");
- adb_getLogsType_set_serviceTag(request, env, service);
-
- in = adb_GetLogs_create(env);
- adb_GetLogs_set_GetLogs(in, env, request);
-
- out = axis2_stub_op_EucalyptusGL_GetLogs(stub, env, in);
- if (!out) {
- printf("ERROR: operation call failed\n");
- return(1);
- }
- response = adb_GetLogsResponse_get_GetLogsResponse(out, env);
-
- //outservice = adb_getLogsResponseType_get_serviceTag(response, env);
- *outCClog = adb_getLogsResponseType_get_CCLog(response, env);
- *outNClog = adb_getLogsResponseType_get_NCLog(response, env);
- *outHlog = adb_getLogsResponseType_get_httpdLog(response, env);
- *outAlog = adb_getLogsResponseType_get_axis2Log(response, env);
-
- return(0);
+int gl_getLogs(char *service, char **outCClog, char **outNClog, char **outHlog, char **outAlog, axutil_env_t * env, axis2_stub_t * stub)
+{
+ char *outservice;
+
+ adb_GetLogsResponse_t *out;
+ adb_getLogsResponseType_t *response;
+
+ adb_GetLogs_t *in;
+ adb_getLogsType_t *request;
+
+ request = adb_getLogsType_create(env);
+ adb_getLogsType_set_userId(request, env, "eucalyptus");
+ adb_getLogsType_set_correlationId(request, env, "12345678");
+ adb_getLogsType_set_serviceTag(request, env, service);
+
+ in = adb_GetLogs_create(env);
+ adb_GetLogs_set_GetLogs(in, env, request);
+
+ out = axis2_stub_op_EucalyptusGL_GetLogs(stub, env, in);
+ if (!out) {
+ printf("ERROR: operation call failed\n");
+ return (1);
+ }
+ response = adb_GetLogsResponse_get_GetLogsResponse(out, env);
+
+ //outservice = adb_getLogsResponseType_get_serviceTag(response, env);
+ *outCClog = adb_getLogsResponseType_get_CCLog(response, env);
+ *outNClog = adb_getLogsResponseType_get_NCLog(response, env);
+ *outHlog = adb_getLogsResponseType_get_httpdLog(response, env);
+ *outAlog = adb_getLogsResponseType_get_axis2Log(response, env);
+
+ return (0);
}
-int gl_getKeys(char *service, char **outCCCert, char **outNCCert, axutil_env_t *env, axis2_stub_t *stub) {
- char *outservice;
-
- adb_GetKeysResponse_t *out;
- adb_getKeysResponseType_t *response;
-
- adb_GetKeys_t *in;
- adb_getKeysType_t *request;
-
- request = adb_getKeysType_create(env);
- adb_getKeysType_set_userId(request, env, "eucalyptus");
- adb_getKeysType_set_correlationId(request, env, "12345678");
- adb_getKeysType_set_serviceTag(request, env, service);
-
- in = adb_GetKeys_create(env);
- adb_GetKeys_set_GetKeys(in, env, request);
-
- out = axis2_stub_op_EucalyptusGL_GetKeys(stub, env, in);
- if (!out) {
- printf("ERROR: operation call failed\n");
- return(1);
- }
- response = adb_GetKeysResponse_get_GetKeysResponse(out, env);
-
- //outservice = adb_getKeysResponseType_get_serviceTag(response, env);
- *outCCCert = adb_getKeysResponseType_get_CCcert(response, env);
- *outNCCert = adb_getKeysResponseType_get_NCcert(response, env);
-
- return(0);
+int gl_getKeys(char *service, char **outCCCert, char **outNCCert, axutil_env_t * env, axis2_stub_t * stub)
+{
+ char *outservice;
+
+ adb_GetKeysResponse_t *out;
+ adb_getKeysResponseType_t *response;
+
+ adb_GetKeys_t *in;
+ adb_getKeysType_t *request;
+
+ request = adb_getKeysType_create(env);
+ adb_getKeysType_set_userId(request, env, "eucalyptus");
+ adb_getKeysType_set_correlationId(request, env, "12345678");
+ adb_getKeysType_set_serviceTag(request, env, service);
+
+ in = adb_GetKeys_create(env);
+ adb_GetKeys_set_GetKeys(in, env, request);
+
+ out = axis2_stub_op_EucalyptusGL_GetKeys(stub, env, in);
+ if (!out) {
+ printf("ERROR: operation call failed\n");
+ return (1);
+ }
+ response = adb_GetKeysResponse_get_GetKeysResponse(out, env);
+
+ //outservice = adb_getKeysResponseType_get_serviceTag(response, env);
+ *outCCCert = adb_getKeysResponseType_get_CCcert(response, env);
+ *outNCCert = adb_getKeysResponseType_get_NCcert(response, env);
+
+ return (0);
}
@@ -67,8 +67,8 @@
#include <time.h>
#include "axis2_stub_EucalyptusGL.h"
-int gl_getLogs(char *service, char **outCClog, char **outNClog, char **outHlog, char **outAlog, axutil_env_t *env, axis2_stub_t *stub);
+int gl_getLogs(char *service, char **outCClog, char **outNClog, char **outHlog, char **outAlog, axutil_env_t * env, axis2_stub_t * stub);
-int gl_getKeys(char *service, char **outCCCert, char **outNCCert, axutil_env_t *env, axis2_stub_t *stub);
+int gl_getKeys(char *service, char **outCCCert, char **outNCCert, axutil_env_t * env, axis2_stub_t * stub);
#endif
Oops, something went wrong.

0 comments on commit 2c03873

Please sign in to comment.