Browse code

ffserver/ctime1: avoid using strcpy()

Signed-off-by: Michael Niedermayer <michaelni@gmx.at>

Michael Niedermayer authored on 2013/03/26 07:31:34
Showing 1 changed files
... ...
@@ -396,14 +396,14 @@ static int resolve_host(struct in_addr *sin_addr, const char *hostname)
396 396
     return 0;
397 397
 }
398 398
 
399
-static char *ctime1(char *buf2)
399
+static char *ctime1(char *buf2, int buf_size)
400 400
 {
401 401
     time_t ti;
402 402
     char *p;
403 403
 
404 404
     ti = time(NULL);
405 405
     p = ctime(&ti);
406
-    strcpy(buf2, p);
406
+    av_strlcpy(buf2, p, buf_size);
407 407
     p = buf2 + strlen(p) - 1;
408 408
     if (*p == '\n')
409 409
         *p = '\0';
... ...
@@ -416,7 +416,7 @@ static void http_vlog(const char *fmt, va_list vargs)
416 416
     if (logfile) {
417 417
         if (print_prefix) {
418 418
             char buf[32];
419
-            ctime1(buf);
419
+            ctime1(buf, sizeof(buf));
420 420
             fprintf(logfile, "%s ", buf);
421 421
         }
422 422
         print_prefix = strstr(fmt, "\n") != NULL;