Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
DISCONTINUED:openSUSE:11.2:Update
netatalk
netatalk.papd.quote-vars.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File netatalk.papd.quote-vars.patch of Package netatalk
--------------------- PatchSet 2552 Date: 2008/08/14 22:19:19 Author: didg Branch: branch-netatalk-2-0 Tag: (none) Log: quote chars in popen variables expansion Members: etc/papd/lp.c:1.14.8.4.2.1->1.14.8.4.2.2 Index: netatalk/etc/papd/lp.c diff -u netatalk/etc/papd/lp.c:1.14.8.4.2.1 netatalk/etc/papd/lp.c:1.14.8.4.2.2 --- netatalk/etc/papd/lp.c:1.14.8.4.2.1 Thu Aug 14 20:04:16 2008 +++ netatalk/etc/papd/lp.c Thu Aug 14 20:19:19 2008 @@ -212,10 +212,37 @@ #define is_var(a, b) (strncmp((a), (b), 2) == 0) +static size_t quote(char *dest, char *src, const size_t bsize, size_t len) +{ +size_t used = 0; + + while (len && used < bsize ) { + switch (*src) { + case '$': + case '\\': + case '"': + case '`': + if (used + 2 > bsize ) + return used; + *dest = '\\'; + dest++; + used++; + break; + } + *dest = *src; + src++; + dest++; + len--; + used++; + } + return used; +} + + static char* pipexlate(char *src) { char *p, *q, *dest; - static char destbuf[MAXPATHLEN]; + static char destbuf[MAXPATHLEN +1]; size_t destlen = MAXPATHLEN; int len = 0; @@ -224,13 +251,15 @@ if (!src) return NULL; - strncpy(dest, src, MAXPATHLEN); - if ((p = strchr(src, '%')) == NULL) /* nothing to do */ + memset(dest, 0, MAXPATHLEN +1); + if ((p = strchr(src, '%')) == NULL) { /* nothing to do */ + strncpy(dest, src, MAXPATHLEN); return destbuf; - - /* first part of the path. just forward to the next variable. */ + } + /* first part of the path. copy and forward to the next variable. */ len = MIN((size_t)(p - src), destlen); if (len > 0) { + strncpy(dest, src, len); destlen -= len; dest += len; } @@ -246,17 +275,20 @@ q = lp.lp_created_for; } else if (is_var(p, "%%")) { q = "%"; - } else - q = p; + } /* copy the stuff over. if we don't understand something that we * should, just skip it over. */ if (q) { - len = MIN(p == q ? 2 : strlen(q), destlen); + len = MIN(strlen(q), destlen); + len = quote(dest, q, destlen, len); + } + else { + len = MIN(2, destlen); strncpy(dest, q, len); - dest += len; - destlen -= len; } + dest += len; + destlen -= len; /* stuff up to next % */ src = p + 2;
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor