]> granicus.if.org Git - apache/commitdiff
Allow for backwards compatibility for the md5 check...
authorJim Jagielski <jim@apache.org>
Fri, 8 Nov 2013 20:48:16 +0000 (20:48 +0000)
committerJim Jagielski <jim@apache.org>
Fri, 8 Nov 2013 20:48:16 +0000 (20:48 +0000)
if we've read the slotmem data and we are at EOF, then
don't bother checking the md5 and assume all is OK.

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

modules/slotmem/mod_slotmem_shm.c

index 43c1c7fc86c1daf61c5bf43714132a32f7da26fe..8f1fcb29ffdff2c6f665db8cacbe4ce8066ca7ea 100644 (file)
@@ -234,15 +234,25 @@ static apr_status_t restore_slotmem(void *ptr, const char *name, apr_size_t size
                            pool);
         if (rv == APR_SUCCESS) {
             rv = apr_file_read(fp, ptr, &nbytes);
-            if (rv == APR_SUCCESS) {
-                rv = apr_file_gets(digest, APR_MD5_DIGESTSIZE, fp);
-                if (rv == APR_SUCCESS) {
-                    apr_md5((unsigned char*)digest2, ptr, nbytes);
-                    if (!strcasecmp(digest, digest2)) {
-                        rv = APR_EGENERAL;
+            if ((rv == APR_SUCCESS || rv == APR_EOF) && nbytes == size) {
+                /*
+                 * if at EOF, don't bother checking md5
+                 *  - backwards compatibility
+                 *  */
+                if (apr_file_eof(fp) != APR_EOF) {
+                    rv = apr_file_gets(digest, APR_MD5_DIGESTSIZE, fp);
+                    if (rv == APR_SUCCESS) {
+                        apr_md5((unsigned char*)digest2, ptr, nbytes);
+                        if (!strcasecmp(digest, digest2)) {
+                            rv = APR_EGENERAL;
+                        }
                     }
                 }
             }
+            else if (nbytes != size) {
+                /* didn't get it all */
+                rv = APR_EGENERAL;
+            }
             apr_file_close(fp);
         }
     }