]> granicus.if.org Git - apache/commitdiff
fix a potential thread safety issue in mod_mime_magic
authorJeff Trawick <trawick@apache.org>
Sat, 1 Dec 2001 01:22:01 +0000 (01:22 +0000)
committerJeff Trawick <trawick@apache.org>
Sat, 1 Dec 2001 01:22:01 +0000 (01:22 +0000)
(but to be honest I have no idea whether or not this path is
ever used... it seems quite bizarre)

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@92269 13f79535-47bb-0310-9956-ffa450edef68

modules/metadata/mod_mime_magic.c

index b4162bcf9c57a36600226af8340e3d971d514243..7cdcf005618873d23321c7347a728cea68a9258b 100644 (file)
@@ -1722,8 +1722,9 @@ static int match(request_rec *r, unsigned char *s, apr_size_t nbytes)
 
 static void mprint(request_rec *r, union VALUETYPE *p, struct magic *m)
 {
-    char *pp, *rt;
+    char *pp;
     unsigned long v;
+    char time_str[APR_CTIME_LEN];
 
     switch (m->type) {
     case BYTE:
@@ -1754,10 +1755,8 @@ static void mprint(request_rec *r, union VALUETYPE *p, struct magic *m)
     case DATE:
     case BEDATE:
     case LEDATE:
-       /* XXX: not multithread safe */
-       pp = ctime((time_t *) & p->l);
-       if ((rt = strchr(pp, '\n')) != NULL)
-           *rt = '\0';
+        apr_ctime(time_str, APR_USEC_PER_SEC * (apr_time_t)*(time_t *)&p->l);
+        pp = time_str;
        (void) magic_rsl_printf(r, m->desc, pp);
        return;
     default: