src/java.base/share/native/libjli/parse_manifest.c
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File jdk Sdiff src/java.base/share/native/libjli

src/java.base/share/native/libjli/parse_manifest.c

Print this page
rev 11654 : imported patch libjli


 176         return (-1);
 177     if ((bytes = read(fd, eb, ENDHDR)) < 0)
 178         return (-1);
 179     if (ENDSIG_AT(eb)) {
 180         return haveZIP64(eb) ? find_end64(fd, eb, pos) : pos;
 181     }
 182 
 183     /*
 184      * Shucky-Darn,... There is a comment at the end of the zip file.
 185      *
 186      * Allocate and fill a buffer with enough of the zip file
 187      * to meet the specification for a maximal comment length.
 188      */
 189     if ((flen = JLI_Lseek(fd, 0, SEEK_END)) < (jlong)0)
 190         return (-1);
 191     len = (flen < END_MAXLEN) ? flen : END_MAXLEN;
 192     if (JLI_Lseek(fd, -len, SEEK_END) < (jlong)0)
 193         return (-1);
 194     if ((buffer = malloc(END_MAXLEN)) == NULL)
 195         return (-1);
 196     if ((bytes = read(fd, buffer, len)) < 0) {
 197         free(buffer);
 198         return (-1);
 199     }
 200 
 201     /*
 202      * Search backwards from the end of file stopping when the END header
 203      * signature is found.
 204      */
 205     endpos = &buffer[bytes];
 206     for (cp = &buffer[bytes - ENDHDR]; cp >= &buffer[0]; cp--)
 207         if (ENDSIG_AT(cp) && (cp + ENDHDR + ENDCOM(cp) == endpos)) {
 208             (void) memcpy(eb, cp, ENDHDR);
 209             free(buffer);
 210             pos = flen - (endpos - cp);
 211             return haveZIP64(eb) ? find_end64(fd, eb, pos) : pos;
 212         }
 213     free(buffer);
 214     return (-1);
 215 }
 216 


 557     char    *name;
 558     char    *value;
 559     int     rc;
 560     char    *splashscreen_name = NULL;
 561 
 562     if ((fd = open(jarfile, O_RDONLY
 563 #ifdef O_LARGEFILE
 564         | O_LARGEFILE /* large file mode */
 565 #endif
 566 #ifdef O_BINARY
 567         | O_BINARY /* use binary mode on windows */
 568 #endif
 569         )) == -1) {
 570         return (-1);
 571     }
 572     info->manifest_version = NULL;
 573     info->main_class = NULL;
 574     info->jre_version = NULL;
 575     info->jre_restrict_search = 0;
 576     info->splashscreen_image_file_name = NULL;
 577     if (rc = find_file(fd, &entry, manifest_name) != 0) {
 578         close(fd);
 579         return (-2);
 580     }
 581     manifest = inflate_file(fd, &entry, NULL);
 582     if (manifest == NULL) {
 583         close(fd);
 584         return (-2);
 585     }
 586     lp = manifest;
 587     while ((rc = parse_nv_pair(&lp, &name, &value)) > 0) {
 588         if (JLI_StrCaseCmp(name, "Manifest-Version") == 0) {
 589             info->manifest_version = value;
 590         } else if (JLI_StrCaseCmp(name, "Main-Class") == 0) {
 591             info->main_class = value;
 592         } else if (JLI_StrCaseCmp(name, "JRE-Version") == 0) {
 593             /*
 594              * Manifest specification overridden by command line option
 595              * so we will silently override there with no specification.
 596              */
 597             info->jre_version = 0;


 658 {
 659     int     fd;
 660     zentry  entry;
 661     char    *mp;        /* manifest pointer */
 662     char    *lp;        /* pointer into manifest, updated during iteration */
 663     char    *name;
 664     char    *value;
 665     int     rc;
 666 
 667     if ((fd = open(jarfile, O_RDONLY
 668 #ifdef O_LARGEFILE
 669         | O_LARGEFILE /* large file mode */
 670 #endif
 671 #ifdef O_BINARY
 672         | O_BINARY /* use binary mode on windows */
 673 #endif
 674         )) == -1) {
 675         return (-1);
 676     }
 677 
 678     if (rc = find_file(fd, &entry, manifest_name) != 0) {
 679         close(fd);
 680         return (-2);
 681     }
 682 
 683     mp = inflate_file(fd, &entry, NULL);
 684     if (mp == NULL) {
 685         close(fd);
 686         return (-2);
 687     }
 688 
 689     lp = mp;
 690     while ((rc = parse_nv_pair(&lp, &name, &value)) > 0) {
 691         (*ac)(name, value, user_data);
 692     }
 693     free(mp);
 694     close(fd);
 695     return (rc == 0) ? 0 : -2;
 696 }


 176         return (-1);
 177     if ((bytes = read(fd, eb, ENDHDR)) < 0)
 178         return (-1);
 179     if (ENDSIG_AT(eb)) {
 180         return haveZIP64(eb) ? find_end64(fd, eb, pos) : pos;
 181     }
 182 
 183     /*
 184      * Shucky-Darn,... There is a comment at the end of the zip file.
 185      *
 186      * Allocate and fill a buffer with enough of the zip file
 187      * to meet the specification for a maximal comment length.
 188      */
 189     if ((flen = JLI_Lseek(fd, 0, SEEK_END)) < (jlong)0)
 190         return (-1);
 191     len = (flen < END_MAXLEN) ? flen : END_MAXLEN;
 192     if (JLI_Lseek(fd, -len, SEEK_END) < (jlong)0)
 193         return (-1);
 194     if ((buffer = malloc(END_MAXLEN)) == NULL)
 195         return (-1);
 196     if ((bytes = read(fd, buffer, (unsigned)len)) < 0) {
 197         free(buffer);
 198         return (-1);
 199     }
 200 
 201     /*
 202      * Search backwards from the end of file stopping when the END header
 203      * signature is found.
 204      */
 205     endpos = &buffer[bytes];
 206     for (cp = &buffer[bytes - ENDHDR]; cp >= &buffer[0]; cp--)
 207         if (ENDSIG_AT(cp) && (cp + ENDHDR + ENDCOM(cp) == endpos)) {
 208             (void) memcpy(eb, cp, ENDHDR);
 209             free(buffer);
 210             pos = flen - (endpos - cp);
 211             return haveZIP64(eb) ? find_end64(fd, eb, pos) : pos;
 212         }
 213     free(buffer);
 214     return (-1);
 215 }
 216 


 557     char    *name;
 558     char    *value;
 559     int     rc;
 560     char    *splashscreen_name = NULL;
 561 
 562     if ((fd = open(jarfile, O_RDONLY
 563 #ifdef O_LARGEFILE
 564         | O_LARGEFILE /* large file mode */
 565 #endif
 566 #ifdef O_BINARY
 567         | O_BINARY /* use binary mode on windows */
 568 #endif
 569         )) == -1) {
 570         return (-1);
 571     }
 572     info->manifest_version = NULL;
 573     info->main_class = NULL;
 574     info->jre_version = NULL;
 575     info->jre_restrict_search = 0;
 576     info->splashscreen_image_file_name = NULL;
 577     if ((rc = find_file(fd, &entry, manifest_name)) != 0) {
 578         close(fd);
 579         return (-2);
 580     }
 581     manifest = inflate_file(fd, &entry, NULL);
 582     if (manifest == NULL) {
 583         close(fd);
 584         return (-2);
 585     }
 586     lp = manifest;
 587     while ((rc = parse_nv_pair(&lp, &name, &value)) > 0) {
 588         if (JLI_StrCaseCmp(name, "Manifest-Version") == 0) {
 589             info->manifest_version = value;
 590         } else if (JLI_StrCaseCmp(name, "Main-Class") == 0) {
 591             info->main_class = value;
 592         } else if (JLI_StrCaseCmp(name, "JRE-Version") == 0) {
 593             /*
 594              * Manifest specification overridden by command line option
 595              * so we will silently override there with no specification.
 596              */
 597             info->jre_version = 0;


 658 {
 659     int     fd;
 660     zentry  entry;
 661     char    *mp;        /* manifest pointer */
 662     char    *lp;        /* pointer into manifest, updated during iteration */
 663     char    *name;
 664     char    *value;
 665     int     rc;
 666 
 667     if ((fd = open(jarfile, O_RDONLY
 668 #ifdef O_LARGEFILE
 669         | O_LARGEFILE /* large file mode */
 670 #endif
 671 #ifdef O_BINARY
 672         | O_BINARY /* use binary mode on windows */
 673 #endif
 674         )) == -1) {
 675         return (-1);
 676     }
 677 
 678     if ((rc = find_file(fd, &entry, manifest_name)) != 0) {
 679         close(fd);
 680         return (-2);
 681     }
 682 
 683     mp = inflate_file(fd, &entry, NULL);
 684     if (mp == NULL) {
 685         close(fd);
 686         return (-2);
 687     }
 688 
 689     lp = mp;
 690     while ((rc = parse_nv_pair(&lp, &name, &value)) > 0) {
 691         (*ac)(name, value, user_data);
 692     }
 693     free(mp);
 694     close(fd);
 695     return (rc == 0) ? 0 : -2;
 696 }
src/java.base/share/native/libjli/parse_manifest.c
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File