X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;ds=sidebyside;f=cde%2Fprograms%2Fdtinfo%2Fdtinfo%2Fsrc%2FManagers%2FServiceMgrX.C;h=c183673c1b6b910658f52a236d213f1cd49ddd57;hb=297b6bd84552bde1b02ae56296219b626782f80c;hp=411f4ffa4b4d5791754f33c5e36eea34e6a39285;hpb=51b8929ebd7f12c2c262419691df30bcb51ef6ae;p=oweals%2Fcde.git diff --git a/cde/programs/dtinfo/dtinfo/src/Managers/ServiceMgrX.C b/cde/programs/dtinfo/dtinfo/src/Managers/ServiceMgrX.C index 411f4ffa..c183673c 100644 --- a/cde/programs/dtinfo/dtinfo/src/Managers/ServiceMgrX.C +++ b/cde/programs/dtinfo/dtinfo/src/Managers/ServiceMgrX.C @@ -16,7 +16,7 @@ * details. * * You should have received a copy of the GNU Lesser General Public - * License along with these librararies and programs; if not, write + * License along with these libraries and programs; if not, write * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth * Floor, Boston, MA 02110-1301 USA */ @@ -245,7 +245,7 @@ ServiceMgr::process_olias_event (Window client, return; unsigned char event_type = *stream++; - char *infobase; + int len, bufferlen; char *locator; // NOTE: make fixed width and add "mmdb:" to // front ? Should eventually go into calling // program to determine doc type. @@ -258,7 +258,6 @@ ServiceMgr::process_olias_event (Window client, // Skip over the defunct infobase name. // NOTE: It should be removed from the olias api. DJB - infobase = (char *) stream; while (*stream != '\0') stream++; stream++; @@ -273,14 +272,16 @@ ServiceMgr::process_olias_event (Window client, } else { - char *buffer = new char[strlen("mmdb:LOCATOR=") + strlen(locator) + 1]; - sprintf (buffer, "mmdb:LOCATOR=%s", locator); + bufferlen = strlen("mmdb:LOCATOR=") + strlen(locator) + 1; + char *buffer = new char[bufferlen]; + snprintf (buffer, bufferlen, "mmdb:LOCATOR=%s", locator); d = UAS_Common::create (buffer); - if (d != (const int)NULL) + if (d != (const int)0) { // (evil hack alert) g_scroll_to_locator = TRUE; - strcpy (g_top_locator, locator); + len = MIN(strlen(locator), 4096 - 1); + *((char *) memcpy(g_top_locator, locator, len) + len) = '\0'; } delete [] buffer; } @@ -295,7 +296,7 @@ ServiceMgr::process_olias_event (Window client, } end_try; - if (d != (const int)NULL) + if (d != (const int)0) { d->retrieve(); reply_to_client(client, OLIAS_SUCCESS); @@ -398,6 +399,7 @@ olias_send_event (Widget, OliasEvent *event) { char *buffer = NULL; char *locator; + int len, bufferlen; UAS_Pointer d; switch (event->type) @@ -416,20 +418,22 @@ olias_send_event (Widget, OliasEvent *event) } else { - buffer = new char[strlen("mmdb:LOCATOR=") + strlen(locator) + 1]; - sprintf (buffer, "mmdb:LOCATOR=%s", locator); + bufferlen = strlen("mmdb:LOCATOR=") + strlen(locator) + 1; + buffer = new char[bufferlen]; + snprintf (buffer, bufferlen, "mmdb:LOCATOR=%s", locator); d = UAS_Common::create (buffer); delete [] buffer; - if (d != (const int)NULL) + if (d != (const int)0) { // (evil hack alert) if (locator == NULL) return (OLIAS_TIMEOUT); - ON_DEBUG (printf (">>> g_top_locator = %p\n", g_top_locator)); - if (g_top_locator == NULL) + ON_DEBUG(printf(">>> g_top_locator = %p\n", g_top_locator)); + if (g_top_locator[0] == '\0') return (OLIAS_TIMEOUT); g_scroll_to_locator = TRUE; - strcpy (g_top_locator, locator); + len = MIN(strlen(locator), 4096 - 1); + *((char *) memcpy(g_top_locator, locator, len) +len) = '\0'; } } } @@ -442,7 +446,7 @@ olias_send_event (Widget, OliasEvent *event) d = NULL; } end_try; - if (d != (const int)NULL) + if (d != (const int)0) { d->retrieve(); return (OLIAS_SUCCESS); @@ -459,4 +463,6 @@ olias_send_event (Widget, OliasEvent *event) default: return (OLIAS_TIMEOUT); } + + return (OLIAS_LOCATOR_NOT_FOUND); }