Browse code

fix bounds errors (bb#237)

git-svn: trunk@2629

Tomasz Kojm authored on 2007/01/16 04:39:10
Showing 2 changed files
... ...
@@ -1,3 +1,7 @@
1
+Mon Jan 15 20:37:16 CET 2007 (tk)
2
+---------------------------------
3
+  * libclamav/lockdb.c: fix bounds errors (bb#237), patch from Edwin
4
+
1 5
 Mon Jan 15 01:38:46 CET 2007 (tk)
2 6
 ---------------------------------
3 7
   * freshclam/mirman.c: fix mirror access time printout on win32 (bb#221)
... ...
@@ -262,12 +262,12 @@ static void cli_lockname(char *lock_file, size_t lock_file_size, const char *dbd
262 262
 	    *c = '/';
263 263
 #endif
264 264
 	case '/':
265
-	    if(*(c-1) == '/') { /* compress imbedded // */
265
+	    if(c!=lock_file && *(c-1) == '/') { /* compress imbedded // */
266 266
 		--c;
267
-		strcpy(c, c+1);
268
-            } else if((*(c-2) == '/') && (*(c-1) == '.')) { /* compress imbedded /./ */
267
+		memmove(c, c+1,strlen(c+1)+1);
268
+            } else if(c > lock_file+1 && (*(c-2) == '/') && (*(c-1) == '.')) { /* compress imbedded /./ */
269 269
 		c -= 2;
270
-		strcpy(c, c+2);
270
+		memmove(c, c+2,strlen(c+2)+1);
271 271
             }
272 272
 	    break;
273 273
 #ifdef C_WINDOWS