Opened 19 years ago

Closed 19 years ago

#1197 closed defect (fixed)

msSetError doesn't zero terminate routine name

Reported by: jerry.pisk@… Owned by: sdlime
Priority: high Milestone:
Component: MapServer C Library Version: 4.4
Severity: major Keywords:
Cc: sgillies@…

Description

If a routine name is longer then ROUTINELENGTH then msSetError fails to zero 
terminate it in the new errorObj object.

Attachments (1)

maperror.c.patch (552 bytes ) - added by jerry.pisk@… 19 years ago.
maperror.c patch

Download all attachments as: .zip

Change History (6)

by jerry.pisk@…, 19 years ago

Attachment: maperror.c.patch added

maperror.c patch

comment:1 by sdlime, 19 years ago

Cc: mapserver-bugs@… added
CC'ing Dan et al for review...

Steve

comment:2 by sgillies@…, 19 years ago

Cc: sgillies@… added

comment:3 by dmorissette, 19 years ago

I agree with the patch except that setting ms_error->routine[ROUTINELENGTH]='\0'
will write one byte past the end of the buffer. The last byte in the buffer is
at index ROUTINELENGTH-1, so the patch should become:


Index: maperror.c
===================================================================
RCS file: /data2/cvsroot/mapserver/maperror.c,v
retrieving revision 1.61
diff -u -r1.61 maperror.c
--- maperror.c	28 Jan 2005 06:16:53 -0000	1.61
+++ maperror.c	30 Jan 2005 18:38:04 -0000
@@ -295,8 +295,10 @@
 
   if(!routine)
     strcpy(ms_error->routine, "");
-  else
+  else {
     strncpy(ms_error->routine, routine, ROUTINELENGTH);
+    ms_error->routine[ROUTINELENGTH-1] = '\0';
+  }
 
   if(!message_fmt)
     strcpy(ms_error->message, "");

comment:4 by sdlime, 19 years ago

Status: newassigned
Applied Dan's modified patch, thanks to both of you guys.

Steve

comment:5 by sdlime, 19 years ago

Resolution: fixed
Status: assignedclosed
Closing, already patched.
Note: See TracTickets for help on using tickets.